Day 56: Getting data from Spott Api

mtee

Margaret W.N

Posted on September 10, 2020

Day 56: Getting data from Spott Api

I worked on consuming the spot api. I got one part right today getting back the data from the API. I'm still trying to filter out the responses to autoupdate the city and country.

const input = document.getElementById("input");
input.addEventListener('keyup', async (input)=> {

    const typedString = document.getElementById("input").value;

    await fetch(`https://spott.p.rapidapi.com/places/autocomplete?q=${typedString}&limit=10&skip=0&type=CITY&language=ar`, {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "spott.p.rapidapi.com",
        "x-rapidapi-key": "insertKey"
    }
})
.then(response => {
    let data = response.json();
    console.log(data);

const country = document.querySelector('country');
country.textContent = data.name

})
.catch(err => {
    console.log(err);
});
})
Enter fullscreen mode Exit fullscreen mode

Day 55

πŸ’– πŸ’ͺ πŸ™… 🚩
mtee
Margaret W.N

Posted on September 10, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Day 23 of 100DaysOfCode
javascript Day 23 of 100DaysOfCode

October 3, 2024

Day21 of 100DaysOfCode
javascript Day21 of 100DaysOfCode

August 22, 2024

Day22 of 100DaysOfCode
javascript Day22 of 100DaysOfCode

September 7, 2024

Day 2 of #100daysofMiva Coding Challenge
100daysofmiva Day 2 of #100daysofMiva Coding Challenge

August 22, 2024