I am making a fetch post to a service. When using Postman the request works perfectly fine. But when using Wix, I get a message from the server saying “Internal Server Error”. I am sending a base64 Image. Is Wix limiting the body size of the request?
The code:
import { fetch } from 'wix-fetch';
export function getImageId(imageData) {
//console.log("Getting called");
imageData = imageData.replace("data:image/png;base64,", "")
console.log(imageData)
fetch("url", {
method: "post",
headers: {
"x-api-key": "api-key",
"Content-Type": "application/json",
},
body: {
"styleId": "b909ea37-9763-4df0-a7fd-d7b10d2f1309",
"imageBase64Encoded": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAHYCAYAAABOalMyAAAgAElEQVR4Xux9d3wU1fr+MzM725NND70EBCmKoEgTEEHELohiV1T8XUW/Kha8iu1iV1REEbteFb0U27UgKHKlgyKg9JYQUgjp23dnZ36fc3YXAgLZ3WxCkn3n/oH3k3NmZ55z5pl33vK8gqZpGuggBAgBQoAQaPYICET4zX6N6QYJAUKAEOAIEOHTRiAECAFCIEEQIMJPkIWm2yQECAFCgAif9gAhQAgQAgmCABF+giw03SYhQAgQAkT4tAcIAUKAEEgQBIjwE2Sh6TYJAUKAECDCpz1ACBAChECCIECEnyALTbdJCBAChAARPu0BQoAQIAQSBAEi/ARZaLpNQoAQIASI8GkPEAKEACGQIAgQ4SfIQtNtEgKEACFA...",
}
})
.then((httpResponse) => {
console.log(httpResponse.bodyUsed)
if (httpResponse.ok) {
return httpResponse.json();
} else {
return httpResponse.json();
//return Promise.reject("Fetch did not succeed");
}
})
.then((json) => {
console.log("Data")
console.log("Json", json)
})
.catch(err => console.log(err));
}