开发者

Querying JSON API with node.js

开发者 https://www.devze.com 2023-03-09 19:36 出处:网络
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/map开发者_C百科s/api/geocode/js

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/map开发者_C百科s/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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号