Why can't I save json data for use outside the json function?

I’ve been struggling with this for weeks. It seems the only way I can make an api work is if I build everything inside the json api function, which is fine for the challenge, but I want to use two or three different api’s, and nesting them doesn’t work.

Why does the variable defined globally at the top not retain data saved to it in the function, and then logged out at the end?

Ah, okay. So this particular issue is kind of a quirk of jQuery. How would one use multiple api’s then? When I have tried nesting them, none of them work.

Fair. By quirk, I just mean that basic javascript expectations don’t apply. So like, a quirk to me, a novice.

Is there some way to ‘import’ the json data for use outside the json function?

This is basic JS: it’s not a quirk, it’s literally how JS works. JS has a single thread in which to do things: it does thing one after the other, straightway, so if you need to do something that takes time (eg any user input, requests to remote servers, interacting with the outside world, etc), you need to hold onto the values, which you do by using closures, which in practice means code that needs time happens inside callbacks.