Help

Getting JSON and populating an AirTable field

Topic Labels: Scripting extentions
Solved
Jump to Solution
1956 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Kosta_Kondraten
7 - App Architect
7 - App Architect

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?

1 Solution

Accepted Solutions
Vivid-Squid
11 - Venus
11 - Venus

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

let json = response.JSON()

See Solution in Thread

2 Replies 2
Vivid-Squid
11 - Venus
11 - Venus

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

let json = response.JSON()
Kosta_Kondraten
7 - App Architect
7 - App Architect

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: