Closed counselorbot[bot] closed 2 years ago
Move on to the next issue.
Go ahead and merge this branch to main
to move on. Great work finishing this section!
⚠️ If you receive a
Conflicts
error, simply pressResolve conflicts
and you should be good to merge!
Week 4 Step 5 ⬤⬤⬤⬤⬤◯◯ | 🕐 Estimated completion: 5-20 minutes
Create the CataaS Website ~ meow
Demo: 🐱
Create a website that return a picture from the CatAAS API with the name of the cat being the input (each click should call the Cataas API)
✅ Task:
twocatz-frontend
branchcatzapp/index.html
with a text input (type="text"
) and a button (type="button"
) that calls the Javascript functiony1k3s()
intwocatz/index.js
img
object with idimage
incatzapp/index.html
y1k3s()
function that replaces theimg
div with a picture from the CataaS API containing input from the text boxcatzapp/index.html
andcatzapp/script.js
to thetwocatz-frontend
branchtwocatz-frontend
tomain
, and only merge the pull request when the bot approves your changes!🚧 Test your Work
Open up your LiveServer plugin and start your local server. To test your web app:
⚠️ When you enter "catzrule" into the textbox and click the button, is there a picture that appears with a cat and "catzrule" on it?
1: Creating an HTML template
In Visual Studio Code, you can create a html template containing the basic header tags by typing
!
+Tab
. This will create something like:2: Getting the Cat Pic
The
img
tag embeds an image, and it has attributes. We'll be usingsrc
.:question: How can I modify src to get the picture?
When the button is clicked, it will call `y1k3s()`, so we will add a line of code in the function. In HTML, the img tag looks like this: ```html ``` We can change the `src` value to a URL, or a file on a server. In our case, we'll change it to a URL to the Cat API. > 💡 Recall that the endpoint is https://cataas.com/cat/says/[your_text] ```js document.getElementById("YOUR_IMAGE_ID").src = THE_ENDPOINT + THE_INPUT ```📹 Walkthrough Video