Currently I have the following statement for return an array from a get route:-
return res.json(dataChunk);
Now I also have another array results[1] which I also want to return. So how to do it?
You only get one response from a given request. So, if you want to respond with two separate pieces of data, you need to combine them somehow into a single response and send that. You can either merge their data into one data structure or you can send an object with multiple properties where each property represents one piece of you data.
Without seeing the actual code for your request handler, we can't really know exactly what to suggest, but if you had two separate pieces of data dataChunk and results[1] available at the same time and wanted to send them both, you would just do:
res.send({data: dataChunk, results: results[1]});
This would make the response by an object with two properties data and results and the recipient of the response could examine both properties to get both pieces of the response.
You want to return multiple things from a response? Just wrap it in an object.
const myArray = [1, 2, 3]
const myObject = { foo: 'bar'}
res.json({ myArray, myObject })