Directly copied from Corvid example..
Can any one give me an idea why I am getting the problem in the topic when I run the code.
// Backend
import {fetch} from 'wix-fetch';
export function getCurrentTemp(city) {
const url = 'https://api. openweathermap. org/data/2.5/weather?q=';
const key = '<api key>';
let fullUrl = url + city + '&appid=' + key + '&units=imperial';
return( fetch(fullUrl, {method: 'get'})
.then(response => response.json())
.then(json => json.main.temp)) ;
}
// Front End
import {getCurrentTemp} from 'backend/aModule';
export function getTemp_click(event) {
console.log('Button Pushed')
getCurrentTemp($w("#textInputCity").value)
.then(temp => $w("#textTemp").text = temp + "°");
}
First, don’t post your API key in the forum.
Regarding your problem, you should check to make sure that the API is correct. Why do you have < > in the key?
To add further, please note that there are two fully made up examples in Wix Corvid examples that you can make use of here too.
https://www.wix.com/corvid/example/create-a-weather-widget
https://www.wix.com/corvid/example/secrets-manager
Plus, if you look at the Wix Fetch page that you used for this…
https://support.wix.com/en/article/corvid-accessing-third-party-services-with-the-fetch-api
It does state there…
To make this example work, you’d have to replace with your own API key.
So you should have replaced all of that including the <> with your own key.
Thanks, the problem was fixed by removing <> around the api.
Jerry