I am trying to recieve temperature from a weather api that has the pathing main.temp with this code.
serviceModule.jsw (backend)
import {fetch} from 'wix-fetch';
export function getCurrentTemp(city) {
const url = 'http://api.openweathermap.org/data/2.5/forecast?q=';
const key = 'API-KEY';
let fullUrl = url + city + ',se&appid=' + key + '&units=metric';
return fetch(fullUrl, {method: 'get'})
.then(response => response.json())
.then(json => json.main.temp);
}
frontend
import {getCurrentTemp} from 'backend/serviceModule';
export function buttonFetchTemp_click(event) {
getCurrentTemp($w("#textInputCity").value)
.then(temp => $w("#textTemp").text = temp + "°");
}
I have button and textinput and a text to display the result but when i try it on live. I get that error from earlier and the console error looks like this.
Any idea why?