derekturner
derekturner11mo ago

This should be simple (accessing value from response object using dot notation).

I am looking to grab a value from an object that is returned in an API response object. I would assume I could do with dot notation. The AI is suggesting the same, however it does not work. Getting an 'undefined' error. Grabbing the entire object works as expected, however trying to get the 'id' value from the object throws the error.
No description
No description
No description
4 Replies
Gaurav Chadha
Gaurav Chadha10mo ago
Hi, @derekturner, you can definitely access values using dot notation. The issue I see from the above is, your response is in the array and you'll require to use index to access the specific object in the array and then use dot notation to access the "id" property. Please refer to the example picture attached, you'll be able to access the id.
No description
Leo De Stefanis
Leo De Stefanis6mo ago
How to use a wildcard to get all the elements without specifying an index? In short, I would need to get all the elements regardless their position - i.e. if I have 100 objects, I want a response that includes all of them, from position 0 to position 99).
Guiz
Guiz6mo ago
You should use the map function but it will return an array as well. You will have an array instead of an array of object. It should be something like this : FetchSampleArray.map(row => row.id);
Gaurav Chadha
Gaurav Chadha6mo ago
Yes, a custom map function will work here, or you can use nested loop node, @Leo De Stefanis, I'll share the workflow copy via-email.
No description