Rest Request JSON File nested #10488
-
Hello everyone, I'm having an issue with a REST request that returns nested JSON data. I've been trying to split the data using a "Transformer", but it's not working. Here's an example of the JSON data (with random data placeholders): Details
{ And here's the query I've been using with the transformer: function transform(data) {
const result = [];
const objects = data.objects;
for (const key in objects) {
const fields = objects[key].fields;
result.push({
tschuess_name: fields.tschuess_name,
tschuess_org_code: fields.tschuess_org_code,
});
}
return { results: result };
}
Unfortunately, this isn't returning any data. Can anyone help me figure out what I'm doing wrong? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hey @Sagestum, The main issue here I believe is with your transformer. You don't need to wrap this in a function. Where you are returning results at the end also doesn't need to be done in this way, just return the results. I've attached screenshots of the whole process from start to finish showing various tabs of the rest area with your rest data. This should hopefully fix your issues! |
Beta Was this translation helpful? Give feedback.
-
Thanks, that helped a log :D |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hey @Sagestum,
The main issue here I believe is with your transformer. You don't need to wrap this in a function. Where you are returning results at the end also doesn't need to be done in this way, just return the results.
I've attached screenshots of the whole process from start to finish showing various tabs of the rest area with your rest data.
Fixed transformer
Response
Schema
Preview
Result
This should hopefully fix your issues!