how to know if a variable is an array or object

external API returns array for multiple items or object (without [ ] ) for single item  depending on the number of items in the result (it is a bit weird but I have to integrate with this). Now when I pass to FE, it wants array otherwise does not work.  I need to find a way to push result to array if only 1 item return or pass directly if list is returned otherwise it does not work... I was trying to build a conditional logic but count does not really work as it counts list items or simple object parameters so if count >1 wont work... Also try merging to an array and array and adding an element to an array but both wont solve as an array merged with object becomes an object... Any other ideas how to solve it? I am sure  has the answer
Other
9 replies