did you know NASA has a free api that serves an astronomy photo of the day ?
get your own api-key from here https://api.nasa.gov:443. (it’s free!)
here’s today’s APOD
here’s a screenshot of the blocks
and here’s the link to remix corrected):
see corrected version later in thread for the new link.
Nice share! It’s great that it works in a browser; many APIs don’t.
Just a note that you need to move the
set blocks inside of the Web_API
Get block for this to work. Otherwise, you’ll likely get a value of “null” from the API. Here’s how it worked for me:
actually i saved the response inside then_do and referred to it outside so it works. (it was a trick i used for testing after i had already received a good response - so i didn’t have to make the web call every time).
thanks for checking though.
It doesn’t work though. Because the
set blocks fire before the API response is received. I guess it may have worked for you but on my phone and in a browser, it just displayed “null” and no image was shown.
If I add debugging blocks like this:
Then this is the result:
You can see that “Getting properties” occurs before “Response received”.
i got a different picture!
that’s because it’s now 2023-01-09 at NASA! so i changed the program appropriately and got the date from the json response.
here are the new blocks:
and the link to the revised program:
thanks for checking, @tatiang!