Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying JSON API with node.js

Tags:

json

node.js

api

How should querying a JSON API be done best in node.js? Is there a module that will simplify this?

I am trying to get the City location from http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452

I would use jQuery to query the API in client-side because it vastly simplifies things. Is there something similar for node.js?

like image 590
Thomas Avatar asked Jun 02 '11 10:06

Thomas


1 Answers

The request module makes http-request very easy. Just place a GET request to your URL and JSON.parse() the response. You might want to use encodeURIComponent() for your query parameters.

like image 97
aggsol Avatar answered Oct 13 '22 10:10

aggsol