Comment on
“Unload your troubles unto me, even if it’s tough to swallow. I’m used to swallowing huge loads.”
Reply in thread
The show "Xavier: Renegade Angel"
Comment on
“Unload your troubles unto me, even if it’s tough to swallow. I’m used to swallowing huge loads.”
Reply in thread
The show "Xavier: Renegade Angel"
Comment on
Trying to get and use JSON from a URL
If you leave out the second 'then()', the return value of the fetch will be your json (wrapped in a Promise). If you're calling fetch in an async function, you can do this:
const out2 = await fetch(url).then(x => x.json()).catch(console.error).
And then out2 will be the exact same as it was in the second 'then', but in the outer scope.
If making your function asyc is not an option, I'm afraid you have to move your logic to the second 'then'.
I recommend looking into javascripts promises. It's the backbone of asynchronous programming, which is very much what you are trying to do.
Good luck, and have fun 🙂