How can I resolve a fetch failed error in JS module on front end?

Hello,

I have code that is using Fetch to send data to a backend app then then calls the frontend API to create a user. The code works except the initial Fetch returns Fetch failed error event though it worked fine. This stops further processing that needs to be done, mainly using the new customer ID. How to fix getting the failed fetch error.

Something else I found. If I comment out the call to the Shopify API to create a new customer, in the backend app, the fetch does not have a failed fetch error.

for (var property in data) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(data[property]);
formBody.push(encodedKey + “=” + encodedValue);
}
formBody = formBody.join(“&”);
let response = await fetch(this.url+endpoint,{method: “POST”,
headers: {‘Content-type’: ‘application/x-www-form-urlencoded’,
authorization: “Bearer ######”},
body: formBody});