I have this regular FETCH code that returns an object called json I want to be able to use the object in another function so I was trying to turn it into a constant but it won’t let me do it
import {fetch} from 'wix-fetch';
// ...
fetch("https://exchangeratesapi.io/api/latest", {method: "get"})
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
} )
.then(json =>
// I AM ABLE TO USE JSON HERE BUT IT WON'T LET ME DECLARE A CONST
console.log(json)
)
.catch(err => console.log(err));
export function Button_click(event, $w) {
// I want to use the oject here
}