In my node REST application I have a function that queries a database for several records and returns an array of objects.
Since I want it to return a JSON object, I need a way to convert the array of objects to a single object with all the records inside.
Unfortunately I can’t find an example on the internet about doing something like this.
Any help would be appreciated.
In my node REST application I have a function that queries a database for
Share
Why would you want to do that ? Its totally fine to JSON stringify an Array of items, you’ll get a structure like
that is probably even an advantage, because you keep the order of items guaranteed.