Hi everyone, I am doing a course on Async JS and I am just now starting with API s so if I am making a simple mistake please point it out.
The server is saying that my key and the URL are correct, so I know the issue is with my function.
Please help, thanks in advance.
// api key PNnISmT0706XkqOp7RWo0fxcAU08R15b
const key = 'PNnISmT0706XkqOp7RWo0fxcAU08R15b'
const getCity = async (city) => {
const base = 'http://dataservice.accuweather.com/locations/v1/cities/search';
// if it starts with a ? it's a query
// use backticks to reference another string inside a string
const query = `?apikey=${key}&q=${city}`;
const response = await fetch(base + query);
const data = await response.json();
//take first posiiton of the array
return data[0];
};
// this is returning a promise
getCity('spokane')
.then(data => console.log(data ))
.catch(err => console.log(err));