Currently, I am utilizing express to handle my REST API functionality. However, when retrieving objects, it is returning a wrapped array instead of a simple array which I would prefer.
This is how my code currently appears:
router.get('/objects', async (req: Request, res: Response) => {
const objects = await getConnection()
.getRepository(Object)
.createQueryBuilder("object")
.getMany();
return res.status(OK).json({objects});
});
The current response looks like this:
{
objects: [
{
id: "11",
name: "Eleven"
},
{
id: "12",
name: "Twelve"
}
]
}
However, I am aiming for the response to be in a simpler format like this:
{
id: "11",
name: "Eleven"
},
{
id: "12",
name: "Twelve"
}