Whenever I try to fetch the public Steam user profile data I get the following error:
(I have replaced my API key and ID with XX since they are not the issue)
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: Gunzip {
_writeState: [Uint32Array],
_readableState: [ReadableState],
readable: true,
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: true,
_transformState: [Object],
_hadError: false,
bytesWritten: 0,
_handle: [Zlib],
_outBuffer: <Buffer 7b 22 72 65 73 70 6f 6e 73 65 22 3a 7b 22 70 6c 61 79 65 72 73 22 3a 5b 7b 22 73 74 65 61 6d 69 64 22 3a 22 37 36 35 36 31 31 39 37 39 36 30 34 33 35 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_level: -1,
_strategy: 0
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XX&steamids=XX',
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
I have tried using all types of Steam Ids, which didn't change the outcome, though incorrect ID types return a 404, ID64 and ID as name return a 200. Also tried setting up CORS headers, which made no difference, so I don't understand why I am getting a response like this. When I put the same API link into the browser URL, I get normally redirected to the JSON page containing all my profile data.
This is my code (I am using node-fetch for fetching the API data):
router.get('/fetch', async(req, res) => {
try {
const steamAPIUser = "https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XX&steamids=XX"
let data = await fetch(steamAPIUser, { method: 'get', headers: { 'Content-Type': 'application/json' }})
log(data)
res.send(data)
} catch(err) {
log(err)
res.send(err)
}
})