Question:
I try to call an external api, but it doesn’t work.
I try the “Hello fetch”, same problem.
My code :
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');
const response = await fetch('https://velo-examples.wixsite.com/training-tester/_functions/randomgreeting', {
mode: 'no-cors',
//credentials: 'include',
method: 'GET',
headers: headers});
console.log(response);
if(response.ok) {
const json = await response.json();
return json.greeting;
} else {
return Promise.reject("Fetch did not succeed");
}
thanks for your help