Hi everyone !
In order to do some debugging, I gathered all my functions in one single piece of code.
This is the return part of my event hook callback function wixStores_onOrderPaid(event)
// 1) [ api_url & requestOptions are defined here ]
// 2) The whole api call works on the back end
return fetch(api_url, requestOptions)
.then((httpResponse) => {
console.log("CONSOLE DISPLAY 1"); // <- This Displays
console.log(httpResponse);
if (httpResponse.ok) {
console.log("CONSOLE DISPLAY 2"); // <- This Displays too !
console.log("THE RESPONSE :::",httpResponse); // <- This Displays as (a) (see right under this box)
return httpResponse.json().then( (a) => {
console.log("AAAAAAAAAA ",a); // <- This DOES NOT DISPLAY IN CONSOLE
return Promise.resolve(a); //<- This never resolves :(
});
} else {
return Promise.reject("Fetch did not succeed");
}
})
.catch((z) => { console.log(z); return z })
(a) : {“url”:“https://MYHIDDENAPI_URL.com”,“status”:200,“statusText”:“OK”,“headers”:{“_headers”:{“content-type”:[“application/json; charset=utf-8”],“etag”:[“W/"24043-XSZSHLYnb+P4eIZIstxQjRFuKLU"”],“function-execution-id”:[“izit46fjdeqd”],“vary”:[“Origin”],“x-powered-by”:[“Express”],“x-cloud-trace-context”:[“a7c73af9fd0fdf361;o=1”],“date”:[“Wed, 17 Feb 2021 14:10:04 GMT”],“server”:[“Google Frontend”],“content-length”:[“147523”],“connection”:[“close”]}},“ok”:true,“body”:{“_readableState”:{“objectMode”:false,“highWaterMark”:16384,“buffer”:{“head”:{“data”:{“type”:“Buffer”,“data”:[123,34,109,121,100,“next”:{“data”:{“type”:“Buffer”,“data”: [LONG SERIES OF NUMBERS…[66,103,65,65,65,65,65,65,65,6
I don’t understand why the json() part never gets resolved, even though the API server works fine, and I get a result if I use the api call on the front end…
Any help is most welcome!
Raphaël