Help

No JSON data?

Topic Labels: Automations
Solved
Jump to Solution
727 2
cancel
Showing results for 
Search instead for 
Did you mean: 
tech_gtt
4 - Data Explorer
4 - Data Explorer

 

 

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?

1 Solution

Accepted Solutions
Alexey_Gusev
12 - Earth
12 - Earth

Hi,
you should await in the line with responce.json as well

See Solution in Thread

2 Replies 2
Alexey_Gusev
12 - Earth
12 - Earth

Hi,
you should await in the line with responce.json as well

Thanks. Always something simple!