Skip to content

djneill/Simple-Mario-Character-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Super Mario Bros Character API

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*

Technology Used

css3 git html5 javascript node.js postman express.js

About

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.

How to use it in your own project

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)
    }
}