Using Google's api I'm able to get places nearby printed to the console
router.get('/', function (req, res, next) {
// Find places nearby
googleMapsClient.placesNearby({
language: 'en',
location: [-33.865, 151.038],
radius: 500,
type: 'restaurant'
})
.asPromise()
.then((response) => {
console.log(response.json.results);
})
.catch((err) => {
console.log(err);
});
});
I want to send the response which has all the places nearby to the client so I can print them in a table using pug.
I'm having trouble sending that data, when I try res.send(response.json.results
I get Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client