I'm getting the following error:
Houston we got an err at getGames in index.js
(node:72197) UnhandledPromiseRejectionWarning: #<Object>
(node:72197) 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(). (rejection id: 2)
(node:72197) [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.
error at getGames rp
Here is the relevant code:
Helper function to get Data from API (rp is request-promise-native)
const getGames = async () => {
return await rp(`https://api.steampowered.com/IDOTA2Match_570/GetTopLiveGame/v1?key=${KEY}&partner=0`)
.catch(err => console.log('error at getGames rp'))
.error(err => console.log('actual error at getGames rp'))
}
I call this every 5 seconds
app.get('/api/update', async (req, res) => {
const data = await getGames()
.catch(err => console.log('Houston we got an err at getGames in index.js'))
const dataJson = JSONbig.parse(data);
if (dataJson.game_list && dataJson.game_list.length) {
for (let i = 0; i < dataJson.game_list.length; i++) {
const game = dataJson.game_list[i];
...
The '/api/update' endpoint gets called every 5 seconds. I get the above error. My for loop stops iterating. I'd like it to skip the one it's error'ing on, but it's saying im not handling the error. I have catch blocks and even error blocks and I can't seem to figure out why this is happening.
I've also tried manually calling:
`https://api.steampowered.com/IDOTA2Match_570/GetTopLiveGame/v1?key=${KEY}&partner=0`
in postman many times in quick succession, but postman never errors out. So the issue is in my code somewhere. I've handled all errors so I can't seem to find what i'm not handling.
Thanks