I get Uncaught (in promise) Fetch did not succeed when calling this on the front end. Also all I want is to return a string from the url, no JSON object, but I cannot find any example.
I need a similar AJAX script where I make calls to the server, and then I can put the result on $w( … ).html()
fetch(‘http://tcokchallenge.com/wjinline.php’, {method: ‘get’,mode: ‘no-cors’})
.then( (httpResponse) => {
let url = httpResponse.url;
let statusCode = httpResponse.status;
let statusText = httpResponse.statusText;
let headers = httpResponse.headers;
let bodyUsed = httpResponse.bodyUsed;
if (httpResponse.ok) {
console.log (httpResponse);
}
else {
return Promise.reject("Fetch did not succeed");
}
} )