DEV Community

Margaret W.N
Margaret W.N

Posted on

2

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

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay