Hello there,
I'm trying to fetch data from a product in one base, then send that information to an external API and then update that new info in other base. The code goes like this:
//input of modified product
let inputConfig = input.config();
//JSON creation
let body = {
"costo_ult": inputConfig.costo_ult[0],
"disponible": inputConfig.disp[0],
"dias_obs": inputConfig.dias_obs[0]
}
console.log(body);
console.log(JSON.stringify(body));
//Send JSON to API
try {
let response = await fetch(`http://167..../${inputConfig.id[0]}`, {
method: 'PATCH',
body: JSON.stringify(body),
headers: {
'Origin': '',
'Content-Type': 'application/json ; charset=utf-8',
'Authorization': 'eyJhb...',
},
});
console.log(await response.json());
}
catch (error) {
console.log(error);
}
The fields I want to update are related to costs, quantities and rotation days, and the response from the script is
- Error {name: "SyntaxError"}
- name: "SyntaxError"
So, can anyone explain me why this is happening and how to solve it? Thanks!