Thank you for responding. My question is not about Airtable’s formatting, it is about how to use the data in the JSON that the API returned.
API is called (accomplished)
JSON is returned (accomplished)
A key pair is pulled from the JSON (???)
In other words, I want a variable called storeNumber with the value of 1234. How do I get that from the JSON?
Thank you for responding. My question is not about Airtable’s formatting, it is about how to use the data in the JSON that the API returned.
API is called (accomplished)
JSON is returned (accomplished)
A key pair is pulled from the JSON (???)
In other words, I want a variable called storeNumber with the value of 1234. How do I get that from the JSON?
The answer depends on where eexactly] you are capturing this data inside Airtable. Is your script running in an automation script? A webhook listener? An external scripting environment?
Please be specific about where your code is running such that it has access to this JSON data.
The answer depends on where [exactly] you are capturing this data inside Airtable. Is your script running in an automation script? A webhook listener? An external scripting environment?
Please be specific about where your code is running such that it has access to this JSON data.
Bill, right now I am in the scripting app, but am open to doing this anywhere in Airtable. I am hitting our company’s API with this script (some info replaced with X’s for privacy):
The console shows me the JSON, but I don’t know how to start using the info in it.
Bill, right now I am in the scripting app, but am open to doing this anywhere in Airtable. I am hitting our company’s API with this script (some info replaced with X’s for privacy):
console.log(storeInfo); //this one gave me the url, status, etc. info about the call
console.log(JSON.stringify(storeInfo)); //this one returned just "{}"
console.log('Store Name:' + storeInfo[0].storeName); //this one errors: Cannot read properties of undefined (reading 'storeName')
The example that you provide does not look like a screen capture. An actual screen capture would be helpful because sometimes the forums changes the formatting when you simply copy/paste in text.
console.log(await storeInfo.json());
It looks like you are getting the information and logging it to the console, without actually saving the data to a variable for future use. Instead, save the result to a variable like this:
const data = await storeInfo.json()
console.log(data)
Then, as Alexey says, you need to understand JavaScript objects and arrays in order to access the individual parts of the data.
The example that you provide does not look like a screen capture. An actual screen capture would be helpful because sometimes the forums changes the formatting when you simply copy/paste in text.
console.log(await storeInfo.json());
It looks like you are getting the information and logging it to the console, without actually saving the data to a variable for future use. Instead, save the result to a variable like this:
const data = await storeInfo.json()
console.log(data)
Then, as Alexey says, you need to understand JavaScript objects and arrays in order to access the individual parts of the data.
Kuovonne, thank you - this is starting to make sense. In your example, you can see in my screencap that storeName is returning as undefined. (I’m wondering if the mistake is that I need to be more specific when pulling “StoreName” out - do I need to be specifying that it is in Object 0?)
Kuovonne, thank you - this is starting to make sense. In your example, you can see in my screencap that storeName is returning as undefined. (I’m wondering if the mistake is that I need to be more specific when pulling “StoreName” out - do I need to be specifying that it is in Object 0?)
Kuovonne, I got it! Thank you!
Kuovonne, I got it! Thank you!
Congrats!
Looks like the top level of the data is an array, versus an object. It was hard to tell in your initial post. Glad you figured it out.