Hello all.
I have an order table with a status column and a dropdown list.
When the status column has no defined values, it launches an automation that needs to run a script every 15 minutes that queries the status via API from a remote server.
I need to properly parse the response from the server and write it to the status column.
At the moment I can't figure out how to pull the json status from the response where the status of the request is and update the desired row.
I will be very grateful for help.
const shopid = 'b6e1835a-85a8-4f34-b445-d9d0934ffcec';
let inputConfig = input.config();
let orders = inputConfig.order;
let table = base.getTable('Orders');
let id = inputConfig.record;
const options = {
method: 'POST',
headers: {
'Accept': 'application/json',
'User-Agent': 'Airtable',
'Content-Type': 'application/json'
},
body: JSON.stringify({
shop_id: `${shopid}`,
tx_id: `${orders}`
})
};
let answer = await fetch(`https://api.roundsquare.biz/v1/status`, options)
.then((response) => response.json())
.then((response) => console.log(response))
.catch(err => console.error(err));
return await table.updateRecorsdAsync( id, {
"order status": response.status
});

