Issues with openweathermap

Hello,

I have signed up and received API,7f9fa5da26147f0ded1e822f103d45a4.

I trying to use the key but I am getting an error “Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.”

And here is my code fetch(‘http://api.openweathermap.org/data/2.5/weather?${searchMethod}=${searchTerm}&APPID=${appId}&units=${units}’)

Can you do us a favor and console.log the url you are fetching?

It appears you are not surrounding your url string with backticks. Instead, it appears you are using single quotes.

Hello @RandellDawson

function searchweather(searchTerm){
getSearchMethod(searchTerm);

fetch(‘http://api.openweathermap.org/data/2.5/weather?${searchMethod}=${searchTerm}&APPID=${appId}&units=${units}’).then(result =>{
return result.json();
}).then(result=>{
init(result);
})
}
function init(resultFromServer)
{
console.log(resultFromServer);
}

'http://api.openweathermap.org/data/2.5/weather?${searchMethod}=${searchTerm}&APPID=${appId}&units=${units}'

That is not a template literal. You need to use backticks instead of single quotes.

Thanks for the feedback but I am still getting an error.