Frustration turned triumph

I was studying up on Class-based components in React to understand lifecycle methods. I ran across a ton of free public APIs and found one that I really liked; It's a database of plants. So I signed up and started trying to use the API. I was running into an issue where I could not get the data back from a GET request to the API due to CORS. I researched the issue but was unable to get it to work. It was late. I was tired.

So I started working on it today, with fresh eyes and a positive spirit. Then the frustration crept in as I ran into the same problems as last night. I was about to just give up and scrap the idea when I found a solution. I added the API endpoint URL to my package.json file as a proxy address:

"proxy": ""

It worked! I was overjoyed and felt a tiny bit of triumph over an issue that I'll probably laugh at in the next few months. I now need to read up more on CORS and why this happens. You'd think I would have got it by now, seeing as how I had to read through countless documentation articles and forums. I'll throw it on the to-do list and come back to it later this week.

Tonight I worked on my Plants app and got stuck on an issue where I couldn't call a function from a child class-based component. It helps to add the function as a prop to the right component.... Yep. Things like that happen and make it seem like maybe you're losing your mind. Then you figure it out and all is well... until it happens again. Haha

Twas a good day :)


more blogs

copyright © 2022 Albert Padilla all rights reserved