![]() |
Take a look at it here on Render 👉 https://super-mario-bros-character-api.onrender.com/
*Render does take a minute to spin up the first time*
This is a simple API with the character objects stored server side. When you enter the characters name it will display thier name, ability, the first game they appeared in, and their picture.
Place this url in your fetch - `https://super-mario-bros-character-api.onrender.com/api/${characterName}`
${characterName} should take the input value from ~input type="text"~ if you're using a search bar or ~input type="radio"~ if you're using a radio button.
Your client side javascript fetch would look like this.
async function apiRequest() {
const characterName = document.querySelector('#searchBar').value.toLowerCase()
try {
const response = await fetch(`https://super-mario-bros-character-api.onrender.com/api/${characterName}`)
const data = await response.json()
console.log(data)
document.getElementById('name').innerText = data.name
document.getElementById('strength').innerText = data.strength
document.getElementById('origin').innerText = data.origin
document.querySelector('img').src = data.image
} catch (error) {
console.log(error)
}
}