xDimGG / node-steamapi

An object-oriented Steam API wrapper for Node.js developers.
https://www.npmjs.com/package/steamapi
177 stars 43 forks source link

Error: Internal Server Error #25

Closed ZackaryH8 closed 2 years ago

ZackaryH8 commented 3 years ago

I receive this error specifically when I try and use getUserStats method. The others seem to work fine.

Code

const SteamAPI = require('steamapi');
const steam = new SteamAPI('APIKEY IS  HERE');

steam.getUserStats('76561198259915581', '730').then((data) => {
    console.log(data);
});

Error

(node:24892) UnhandledPromiseRejectionWarning: Error: Internal Server Error
    at IncomingMessage.<anonymous> (C:\Users\Zack\Documents\Scripting Projects\Steam-API\node_modules\steamapi\src\utils\fetch.js:28:47)
    at Object.onceWrapper (events.js:420:28)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1226:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24892) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, 
or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24892) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
joshuajeschek commented 3 years ago

I get the same error, and I think this happens when the user's profile is private.

patkub commented 2 years ago

@vanitasboi is correct, you can handle this with a catch block

steam.getUserStats('76561197989862681', '730').then((data) => {
    console.log(data);
}).catch((reason) => {
    console.log("User's data is private")
})