SnaBe / node-steam-market-fetcher

A Node.js wrapper for the Steam Community Market API.
https://www.npmjs.com/package/steam-market-fetcher
MIT License
26 stars 3 forks source link

Refused to set unsafe header "Cookie" #6

Closed RenardFute closed 3 years ago

RenardFute commented 3 years ago

Hi I'm getting this error when I'm trying to get price history. Refused to set unsafe header "Cookie"

I'm using:

And the error occurs when I try to load my page on chrome. PS: I installed CORS unlock because I was getting a lot of CORS error.

Thanks

RenardFute commented 3 years ago

I was on chrome switching to my phone fixed this problem but now I get a 400 error

SnaBe commented 3 years ago

Thanks for reporting the issue!

I'm not familiar with React, so I'm not sure why it throws an error. Can I see how you're performing the request in your application? And I'll try to solve it from there.

As you probably already know, your steamLoginSecure will most likely expire each time you close or change your current browser instance. This would be my guess on why you get the 400 Bad Request error.

Best regards, SnaBe

RenardFute commented 3 years ago

Hi,

Here is my function for getting the price history: `getPriceData() {

    let data: []
    this.priceHistory = []

    const Fetcher = new SteamMarketFetcher({
        currency: 'EUR',
        format: 'json'
    });

    Fetcher.getItemPriceHistory(this.name, this.app, ItemOBJ.cookie).then((prices) => {
        console.log(prices)
        this.handler()
    })
    .catch((error) => {
        console.info(error)
        this.handler()
    })

    return data;
}`

this.app is the appID of the item.

And my cookie is up I keep updating it so I'm pretty shure the error doesn't from here.

If you want the exact error message here it is:

Request failed with status code 400
at node_modules\axios\lib\core\createError.js:15:17 in createError
at node_modules\axios\lib\core\settle.js:16:9 in settle
at node_modules\axios\lib\adapters\xhr.js:53:6 in handleLoad
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:592:4 in setReadyState
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:395:6 in __didCompleteResponse
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
at [native code]:null in callFunctionReturnFlushedQueue

Thanks again for your help.

SnaBe commented 3 years ago

Hey, I haven't any luck replicating the error you're getting.

I'm guessing that the error might be a result of the React or browser environment. However, I'm not sure how that is the case. I'm pretty sure that React uses a bundling tool to compile the node module into code that the browser understands. So, there's a possibility that it is some weird network error related to how Expo and or React interact with a server-side module.

const SteamMarketFetcher = require('steam-market-fetcher');

const Fetcher = new SteamMarketFetcher({
    currency: 'EUR',
    format: 'json'
});

Fetcher.getItemPriceHistory('★ Gut Knife | Doppler (Factory New)', 730, 'COOKIE_HERE').then((prices) => console.log(prices)).catch((err) => console.log(err.message));

I have tried running the above call and have had no issues using Node.js v14.15.0. However, when using Vue.js v2.6.11 and the same code snippet I get a network error.

The module was not developed with browser or frontend framework support in mind. I've not really looked into this, but I assume that the implementation and use may be varying from that of the server-side.

Best regards, SnaBe

RenardFute commented 3 years ago

Hi SnaBe,

Thanks for all the search you done. Sadly I came to the same result: The error is coming from react & expo. I think I will have to do it on a web server then call it from my app.

Thanks again, RenardFute