In JS, in general, you work with objects and arrays. It’s not so easy to understand, but as soon as you do, you will understand JS ))
I’m not a pro developer, but sometimes it’s easier to explain by simple words.
Object is a data type, which have one or many ‘key:value’ pairs
in your example it’s “storenumber” : “1234”, “storename” : “joe’s market”
Value can be string, number (btw, “1234” is a string in your case), Object or Array
Array is a “box” of some values (strings, numbers or Objects or Arrays), usually similar type.
The same format Airtable uses for tables, fields etc info
paste that in new scripting window, put any of your table name, run and hope it will add some understanding ))
const mytable=base.getTable('PUT YOUR TABLE NAME HERE')
output.inspect(mytable)
output.text(mytable.name)
const c=mytable.id
output.text(c)
const flds=mytable.fields // Fields is array of Field objects
flds.forEach(f=>{output.text(f.name);
output.inspect(f) })
output.text('Lets iterate object key-value pairs')
const d=Object.entries(flds[0])
output.inspect(d)
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):
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.
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?)