My First Website: Interacting with an API

Elisabeth Reyes
2 min readJun 16, 2021
FireStorm

For my first website I decided to use my brother Jacob’s favorite super hero. This is FireStorm. Originally an amalgam of Ronnie Raymond and Professor Stein. I could go on quite the tangent about this character even though he’s not my favorite hero, but we’re here to talk about code.

This was my first attempt at interacting with an API and it was rough. Thankfully, the Fates favored me. I was able to find https://superheroapi.com/ids.html which is an API full of every superhero/hero you could possible imagine and it stretches far outside the realm of Detective Comics. You will need to use your FaceBook login to gain an access token, but from there it’s endless resources.

After some searching through all the information this API had to offer, I settled on using FireStorm’s first appearance. In order to access an API a fetch request must be used. The Fetch API lets you asynchronously request for a resource. Using fetch() returns a promise that resolves into a response object. In order to get the data, you call one of the response objects, json() .

This is my code for how I called the API using fetch. I returned a response through json(). Then in order for it to call the specific information that I wanted after calling the whole API for FireStorm, I returned it again and used dot notation ‘.’ to access the object and have it return the value: ‘FireStorm #1(March 1, 1978)’ which went with the key: ‘first-appearance’.

--

--