uber api中的错误请求错误

时间:2017-05-01 20:24:09

标签: node.js express uber-api

我一直试图让优步价格估算端点正常工作,但我仍然遇到一个错误,导致我出现一个空白页面,"错误请求。"控制台还说"回调不是功能"但我似乎无法找出问题所在。

我的路线:

//  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);
          });
    }
});

感谢任何帮助。

1 个答案:

答案 0 :(得分: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); });

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