Skip to main content
Solved

No JSON data?

  • November 24, 2023
  • 2 replies
  • 31 views

Forum|alt.badge.img+2

 

 

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?

Best answer by Alexey_Gusev

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

2 replies

Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • Answer
  • November 24, 2023

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


Forum|alt.badge.img+2
  • Author
  • New Participant
  • November 25, 2023

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


Thanks. Always something simple!