9

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?

2
  • What's wrong with a GET http.request to the URL? Commented Jun 2, 2011 at 13:13
  • @Raynos: it's too low level. You need to combine data chunks, to begin with. No automatic redirect following etc. Commented Feb 27, 2013 at 12:57

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.