You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to return only the data for data to the user, i.e.
[{
"id": "f4376e0ab6454cbc8c865205bca7eff2"
}]
When I set “target”: “data” and “output_encoding”: “json-collection”, krakend always returns an empty result with only “[]”, when I remove “target”: “data” it will When I remove the “target”: “data” and set "output_encoding": "json", it returns the full data, but I only want the “data” field.
I've compared to other api's and when the backend returns a data structure as
In this case “target”: “data” will extract the “data” correctly and return it to the user. The difference between them is that one of the structs of “data” is “{}”, while the other is a collection “[]”.
The json-collection encoding expects that the response from the backend is an object named collection that contains inside the array you want to return. Instead of doing a target, what you need is to rename the data property to collection and remove the rest of the noise. This is a working configuration you can try locally that does what you need:
Environment info:
Describe what are you trying to do:
When my backend api returns a data structure of
I would like to return only the data for data to the user, i.e.
When I set “target”: “data” and “output_encoding”: “json-collection”, krakend always returns an empty result with only “[]”, when I remove “target”: “data” it will When I remove the “target”: “data” and set "output_encoding": "json", it returns the full data, but I only want the “data” field.
I've compared to other api's and when the backend returns a data structure as
In this case “target”: “data” will extract the “data” correctly and return it to the user. The difference between them is that one of the structs of “data” is “{}”, while the other is a collection “[]”.
Your configuration file:
Answers would be greatly appreciated.
The text was updated successfully, but these errors were encountered: