Hello Community,
I am new to Retool, and learning as I make progress. I connected a GraphQL API that returns a response like the one below
{
"data": {
"search": {
"total": 874,
"business": [
{
"name": "Blue Fox Cafe",
"location": {
"address1": "919 Fort Street",
"address2": "Suite 101",
"address3": "",
"city": "Victoria",
"state": "BC",
"postal_code": "V8V 3K3",
"country": "CA"
},
"url": "https://www.yelp.com/biz/blue-fox-cafe-victoria?adjust_creative=tTi2ykxmpxGNlVIrxtNbWA&utm_campaign=yelp_api_v3&utm_medium=api_v3_graphql&utm_source=tTi2ykxmpxGNlVIrxtNbWA",
"display_phone": "+1 250-380-1683",
"categories": [
{
"title": "Breakfast & Brunch"
}
]
}
]
}
}
}
What I see in the output table is below
What I want it that based on the response, the location data, I create column for each address1, address2, address2, state, city and fill the data in the table in those respective columns.
I am not sure how to do that. Can someone guide me, please?
Thank you
UPDATE 1
I tried creating a transformer with following code
// type your code here
// example: return formatDataAsArray(data).filter(row => row.quantity > 20)
const getEntries = (o) =>
Object.entries(o).flatMap(([k, v]) =>
Object(v) === v ? getEntries(v) : [ [`${k}`, v] ]
)
const businesses = data.search.business.map(b => Object.fromEntries(getEntries(data.search.business)))
const newData = Object.assign({}, data, {search: {business: businesses}})
//console.log(data)
//console.log(newData)
return newData
After this, all rows have same data, so I am sure, I am doing something wrong here