The GET JSON response is an array i.e.
[
{“name”:“Joe Bloggs 0",“email”:"joe.bloggs0@gmail.com”},
{“name”:“Joe Bloggs 1",“email”:"joe.bloggs1@gmail.com”},
{“name”:“Joe Bloggs 2",“email”:"joe.bloggs2@gmail.com”}
]
there is no name associated with the array value.
When I select “Modify call types” in the “API Calls”, Bubble does not detect that the response is an array. It just detects the the first element in the array,
{“name”:“Joe Bloggs 0",“email”:"joe.bloggs0@gmail.com”}
and displays name & email in the Returned Values dialog. If I select “Show raw response”, I can see all the elements in the array.
Is this a bug?
I’ve run into this too and interested in what others have done. I’ve only been able to display all the values in a single text string that is comma separated (I think…)
Hi, anyone have figured something out for this case?
Or do we really need to do api call for each of the array item listed?
like
api call for https://example.com/api/joe-bloggs-0/
another for https://example.com/api/joe-bloggs-1/
thks
It looks like its a UI problem & data is parsed & can be accessed.
If you create a Repeating Group & connect the Data Source of the Repeating Group to “Get Data from External Api”. Then in the “Get Data from Api” pop-up window set Api Provider to the Api call that is returning the array.
Remember to set the “Type of Content” of the Repeating Group. You will be prompted by Bubble to set it & it will have the same name as the Api call you have defined in the Plugin.
Then you can use cells in the Repeating Group to retrieve the name & email for each index in the array
I believe the trick if you want to name each list within the API Connector is to give the entire array a label. This will only be possible if you have control over how the application you are connecting to presents its JSON back to you.
i.e. you want it to look like:
{“array”:
[
{“name”:“Joe Bloggs 0",“email”:"joe.bloggs0@gmail.com”},
{“name”:“Joe Bloggs 1",“email”:"joe.bloggs1@gmail.com”},
{“name”:“Joe Bloggs 2",“email”:"joe.bloggs2@gmail.com”}
]}
Yes, thanks to @grehancl 's advice i just managed to extract each element of an array with the help of “item #”: