Skip to main content
Solved

Getting JSON and populating an AirTable field

  • June 1, 2022
  • 2 replies
  • 38 views

Forum|alt.badge.img+12

I am creating a proof of concept script which you can see below:

const data = { title: 'AirTable Pusher', content: 'Push, push, push this.', excerpt: 'The short version' };

let response = await remoteFetchAsync('https://staging2.conveyancingqld.com/the_vision.php', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
        'Content-Type': 'application/json',
        'Authorization' : 'Basic d2h5d29udHlvdWNvbm5lY3Q6Y2N1WSAxWWhkIDdsTmkgMzdWSSB5MVlyIDYySEs='
    },
});
console.log(response);

The return on the server side if you check at the time of this writing is:
{“a”:1,“b”:2,“c”:3,“d”:4,“e”:5}

It returns some JSON data - I want to access that in the AirTable script - however when I check the Console log response it says the following:

{type: "basic", url: "https://staging2.conveyancingqld.com/the_vision.php", status: 200, statusText: "OK", ok: true…}
type: "basic"
url: "https://staging2.conveyancingqld.com/the_vision.php"
status: 200
statusText: "OK"
ok: true
headers: Object
redirected: false

Without any reference to the JSON that is returned.

How do I access the JSON variables returned?

Best answer by Vivid-Squid

Hi @Kosta_Kondratenko
I think you need to turn the response into JSON. Try:

let json = response.JSON()

2 replies

Forum|alt.badge.img+16
  • Inspiring
  • 529 replies
  • Answer
  • June 1, 2022

Hi @Kosta_Kondratenko
I think you need to turn the response into JSON. Try:

let json = response.JSON()

Forum|alt.badge.img+12
  • Author
  • Inspiring
  • 46 replies
  • June 2, 2022

Thank you! It worked!

I think I was trying with response.json without the brackets ().

Really appreciate it and will mark your answer as solution :pray: