First Flatiron Project — JavaScript

Tish Faroul
2 min readJul 5, 2021

--

When I began this project, I initially sought to use a public API. The first I chose was so disorganized that I didn’t think I’d have enough time to sort through it and figure out to make use of it in the timeframe I was given to complete the project.

But trying to work with that API and its errors did teach me something — Cross-Origin Resource Sharing (CORS).

It’s important to read ALL of the errors that appear. I was so worried that I was getting an error, that I neglected to read the final part of the error — which provided a solution.

I was able to fix it by adding “mode” to my fetch:

return fetch(URL,{
mode: “no-cors”,
method: “GET”,
headers: {
“Content-type”: “application/json”
}

After some more time working with this API, though, I ultimately chose to create my own locally hosted json server and work with my own data.

It was while I was watching TV that I came across my topic:

Loki (TV series) on Disney+

My JSON server had some pretty basic information (episode list/summaries, some information about Loki, and a description of the show). I used fetch to display that information on a single web-page.

After that, some bonus things I added were:

  1. A quiz based on the information above.
ex. clicking true for the first one would return an alert saying “wrong!”

2. A generator of movies that Loki was featured in within the Marvel universe.

3. A subscription form.

Clicking “submit” would return an alert saying “submitted”

--

--

Tish Faroul
Tish Faroul

No responses yet