Lab 15 - AJAX
Challenge
Our goal for this lab is to experiment with AJAX and learn more about how it works.
Problems
One of the first things I struggled with in this assignment is with selecting an attribute/element inside an object that is inside an object. I had trouble understanding the way you would format it. I, at first, assumed that it would be something like object[object.attribute], but was thus proven wrong when I got an error message in the console log. I tried again, this time with object.object.attribute and miraculously worked. The funniest thing is that this was the first syntax/formatting method I thought of, because in the chain of things, it sort of made sense. However, I had scraped the idea because the syntax also just looked uncomfortable and I assumed that it wouldn't work.
Another problem I encountered was with images. Basically, the API I was using had image URLS and I wanted to incorporate those images into my output. I had only known how to pull images from my repository/document so this was new to me. I consulted ChatGPT on how to do this and found that I could do this with AJAX and APIs. Essentially, I made it so that the source of the image would be the image URL. I struggled getting the image to actually appear for a bit, until I realized that I needed to put it in this: ${} to get it to work.
Results
Welcome to our lab! Here, you can get any Pokémon to be your starter. We will provide you with a little information about your new partner!