Open carcot opened 2 years ago
Hey! It looks like the exception is happening at the getWebAccessToken
for which you don't have a catch
block, which is why the function fails :)
You should add a try/catch around this, and probably put another while
loop around it if you want to keep retrying when it getWebAccessToken
fails too.
I would also recommend that you add some kind of delay (maybe even exponential delay) between each retry to avoid hammering the Spotify API if something goes wrong. Cheers!
Oh, I see now. Thank you!
Does the accessToken
need to be fetched again each time before the call to getFriendActivity(accessToken)
? (I.e., does it change?)
Thanks for you help.
If you do const token = await buddyList.getWebAccessToken(spDcCookie)
and you console.log(token)
you'll see other fields returned by Spotify including the expiry of the token, I think it's something like an hour? So based on that you should be able to reuse the same token during that period =)
I implemented your previous suggestion and so far so good! I'll let you know after I've had more time to test it. Thanks for your help.
Hey since I had to set up my windows again i get this error too. Before it worked just fine, I never had any problems.
It looks like this for me but since i have no idea what im doing how can I avoid this error?
const buddyList = require('spotify-buddylist')
async function main () {
const spDcCookie = 'my cookie here'
const { accessToken } = await buddyList.getWebAccessToken(spDcCookie)
const friendActivity = await buddyList.getFriendActivity(accessToken)
console.log(new Date())
console.log(JSON.stringify(friendActivity, null, 2))
}
setInterval(main, 60000);
clearInterval(main);
main()
.catch(err => {
console.error(err)
process.exit(1)
})
Every so often when my program calls
buddyList.getFriendActivity(accessToken)
I get the errorand I would like to avoid having this error crash my program. I have tried various workarounds, but I am not a JS expert and was hoping you might be able to help. I thought that following code should work, but it still doesn't work reliably.
where
fulfillWithTimeLimit(timeLimit, task, failureValue)
isDo you have any suggestions on how I can make this work reliably?