Nov 24, 2023 12:20 PM
console.log(`Starting...`);
let table = base.getTable("Imported table");
let inputConfig = input.config();
let last_name_array = inputConfig.last_name.split(' ');
let formatted_first_name = last_name_array.shift();
let formatted_last_name = last_name_array.join(' ');
console.log(`Customer ID: ${inputConfig.customer_id}`)
let response = fetch(`https://api.shop-ware.com/api/v1/tenants/xxxx/customers/${inputConfig.customer_id}`,
{
method: "GET",
headers: {
'X-Api-Partner-Id':'xxxxxx',
'X-Api-Secret':'xxxxxx',
'Accept':'application/json',
'User-Agent':'PostmanRuntime/7.34.0',
},
credentials: 'include',
});
let body_response = await response;
let json_response = body_response.json();
console.log(json_response);
await table.updateRecordAsync(inputConfig.record_id,{
"First Name Formatted": formatted_first_name,
"Last Name Formatted": formatted_last_name,
"Business Name": inputConfig.first_name,
})
The last console.log returns an empty object. I've tried putting the 'await response.json()' in the console.log, but that returns an error saying that the json method is not defined.
Ultimately, I'm just trying to get the data to use in updating my table, but I created this step just to make sure that I was getting back the right format.
Also, note that I have done this same call many times in Postman and received the data with no issue.
What am I missing?
Solved! Go to Solution.
Nov 24, 2023 02:12 PM
Nov 24, 2023 02:12 PM
Hi,
you should await in the line with responce.json as well
Nov 24, 2023 04:03 PM
Thanks. Always something simple!