get an object property only when it's present in the object
Options
![Thierry MARTIN](https://us.v-cdn.net/6037124/user_avatars/2208966.jpg)
Thierry MARTIN
Member ✭
Hi there,
I'm having several troubles manipulating data with Xano 😅
Here is the (first?) trouble of the day.
I get some data from an external API, wich may or may not contains a "styles" and/or "genres" property.
Then, I try to create a new object with a "class" property which value should be the styles value (wich is an array of texts) of the original object or the genres value (same type) if the styles property doesn't exist.
How could I do that?
I tried many combinations but got an error each time the "styles" property doesn't exist in the original object.
I'm having several troubles manipulating data with Xano 😅
Here is the (first?) trouble of the day.
I get some data from an external API, wich may or may not contains a "styles" and/or "genres" property.
Then, I try to create a new object with a "class" property which value should be the styles value (wich is an array of texts) of the original object or the genres value (same type) if the styles property doesn't exist.
How could I do that?
I tried many combinations but got an error each time the "styles" property doesn't exist in the original object.
Comments
-
- you can define the path using the GET filter which will allow you to define a default value such as null in the event that the property doesn't exist. This way you can add in logic like a conditional to do something if the property is/is not equal to null
-
So glad I found this post! This simple filter has allowed me to delete a ton of unnecessary IF/THEN statements I've built out
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback