I have this function in my node js application. I give it the user's location in latitude and longitude, a radius, and a keyword to search. There is an node module named googleplaces that I've been using to pass these value to the GooglePlace API.
function placesRequest(radius, lat, lon, keyword){
var conductor = new googlePlaces(googlePlacesAPIKey, "json");
var parameters = {
radius: radius,
location:[lat, lon],
types:"restaurant",
query:keyword
};
conductor.placeSearch(parameters, function(error, response) {
if (error) throw error;
console.log(response.results) //for debugging
if(response.status=="ZERO RESULTS") return "{results:0}";
return response.results;
});
}
I'm still relatively new to node js and I've been looking up on how to modularize the functions, but I'm not entirely sure how it works. The furthest I've gotten was rewriting the function separately. Is there a quick way of retrieving the response.results data or should I just curl the request?