【问题标题】:Bad Request error in uber apiuber api中的错误请求错误
【发布时间】:2017-09-29 06:35:26
【问题描述】:

我一直试图让 uber 价格估算端点正常工作,但我遇到了一个错误,导致我进入一个空白页面,上面写着“错误的请求”。控制台还说“回调不是函数”,但我似乎无法找出问题所在。

我的路线:

//  Get an upfront fare before requesting a ride
app.get('/v1.2/estimates/price', function(request, response) {
    // extract the query from the request URL
    var query = request.query;

    // if no query params sent, respond with Bad Request
    if (!query || !query.lat || !query.lng) {
      response.sendStatus(400);
    } else { 
          uber.estimates.getPriceForRouteAsync( {
              "product_id": "33de8094-3dc4-4ca9-8f67-243275f57623", 
              "start_latitude": "38.9597897", 
              "start_longitude": "-94.60699369999999",
              "end_latitude": "39.010969", 
              "end_longitude": "-94.61509899999999"
          })
          .then(function(res) {
              log(res);
          })
          .error(function(err) {
              console.error(err);
          });
    }
});

感谢任何帮助。

【问题讨论】:

    标签: node.js express uber-api


    【解决方案1】:

    check out the README for node-uber。该方法不接受 JSON 对象,而是方法调用中的参数:

    uber.estimates.getPriceForRouteAsync(38.9597897, -94.606994, 39.010969, -94.615098) .then(function(res) { console.log(res); }) .error(function(err) { console.error(err); });

    另外,the /estimates/price endpoint returns an array of estimates for each product 也不需要产品 ID。

    【讨论】:

    猜你喜欢
    • 2015-11-21
    • 1970-01-01
    • 2016-05-14
    • 2017-12-01
    • 2015-07-20
    • 2022-01-04
    • 1970-01-01
    • 2018-11-20
    相关资源
    最近更新 更多