node.js - 如何使用 SailsJS 调用 Google API

标签 node.js google-api sails.js

我想使用 GMap API 计算 2 个坐标之间的距离。 无论如何,我正在寻找从 URL 捕获返回数据

https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&key={{myKey}}

我试图搜索,但没有任何目的。 请帮助我或给我关键字。非常感谢!

最佳答案

你可以使用 super 棒的request

来自它的文档:

Request 被设计为最简单的 http 调用方式。它支持 HTTPS 并默认遵循重定向。

var request = require('request');
request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Show the HTML for the Google homepage. 
  }
})

希望有帮助!

关于node.js - 如何使用 SailsJS 调用 Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986179/

相关文章:

javascript - MongoDB 和 Node.js 性能中的查询与过滤器

google-api - 有没有办法告诉谷歌,某些元素与页面无关?

sails.js - 如何通过自动订阅发布/订阅来捕获具有更新的链接集合的事件?

javascript - Passport - 动态覆盖策略

javascript - 从嵌套的 async/await 函数中捕获错误

calendar - 使用 dart 中的 googleapis 库更新日历并将其显示在网页上

google-api - 错误 : invalid_scope - This app hasn't been verified to access

javascript - 随机出现 ECONNREFUSED 错误

node.js - 使用 SailsJS/Express 在请求之间将对象保存在内存中

node.js - 如何避免在清除 gc 期间快速增加内存?