My tool used to call the API via Curl what is working without problems.
Now I want to change it and make it via JavaScript. The code is created and should work, but I get an error while executing the code. I made it as easy as possible and partly hardcoded to get it run once before make it more complex.
The code looks like:
async function run_make(params) {
const { ID } = params;
const url = [https://eu1.make.com/api/v2/scenarios/${ID}/run
];
try {
let response = await fetch(url, {
method: ‘POST’,
headers: {
‘Authorization’: Token fead3e98-ce3d-42b2-b604-f2aa48e3xxxx
,
‘Content-Type’: ‘application/json’ // Hinzugefügt, falls erforderlich
}
});
if (!response.ok) {
throw new Error(HTTP error! status: ${response.status}
);
}
let data = await response.json();
return data;
} catch (error) {
console.error(‘There was a problem with the fetch operation:’, error);
}
}
I tried different changes but always get the error undefined. Got the info of a friend, that it could happen because of CORS. Can you help me with this?