cURL to Fetch

I am trying to allow the user to modify some data in WIX and that updates will also be saved in AirTable. The AirTable API has an example in cURL -
$ curl -v -XPATCH\
-H “Authorization: Bearer YOUR_API_KEY” \
-H “Content-type: application/json” \
-d ‘{
“fields”: {
“Title”: “1”
}’ (edited)
How do i convert this into a Fetch in WIX?

I have tried something like this -
fetch(“” + appId + “/Test1?view=Grid%20view/” + fAirTableRecID, {
method: ‘patch’,
headers: {
Authorization: “Bearer “+apiKey
body: JSON.toString( {
“fields”: {
“Title”: toSaveAirTable.Title,
“C1”: toSaveAirTable.C1,
} // fields
}) //body
}) // fetch
.then ( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject(“Fetch did not succeed”);
}) // then
.catch(err => console.log(“Error: ” + err));

But I got the error -
Error: TypeError: Method patch is not allowed by Access-Control-Allow-Methods.

Does anyone know what is the correct Fetch for this cURL call?



Does anyone has any idea what I have done wrong with the Fetch call?


Hi Ken,

Well, right off I’d say the method “patch” is a problem. Are you calling the fetch() from a Page or from a Public file? If so that might be the problem. There is a note regarding this in the wix-fetch.fetch() documentation:

Certain CORS (Cross-Origin Resource Sharing) requests are restricted when originating from a browser. Usually, GET requests and certain POST requests can be made from your site’s Public , Page , or Site code. All other requests need to be made from your site’s Backend code. If you are experiencing an issue with a fetch() call due to a CORS restriction, move the fetch() call to the backend as described in Accessing 3rd Party Services .

I would suggest trying this from a backend file and see if it works.


OK Thanks Yisrael, I will re-write to backend code first.

Anyway idea what is the correct way to convert the AirTable curl into Fetch?


Hey Ken,

Yeah - I agree that converting to fetch can be sort of tough. You can try this site to automatically convert. Then, you might need a little bit of manual tweaking after the conversion.


1 Like

Thanks! I will try.