2017-05-01 12 views
0

私は、価格の見積もりエンドポイントを稼働させようとしていましたが、「Bad Request」という空白のページにつながるエラーが表示されます。コンソールには「コールバック関数ではない」と書かれていますが、何が間違っているのか分かりません。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

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として必要ありません。

+0

推定エンドポイントに必要な権限とコンテンツヘッダーはありますか? – 4ked

+0

[Uber Developerドキュメント:server_tokenまたはaccess_tokenがauthとして必要です](https://developer.uber.com/docs/riders/references/api/v1.2/estimates-price-get#authorization)。 JSONのコンテンツヘッダーはオプションです。 – agraebe

+0

私はあなたの変更に適応して、ドキュメントとノード・ウーバー・レポでそれについて読んでいますが、私はまだ同じエラーを受けています。なぜこれが問題であるかに関するアイデアですか?コンソールにエラーはありません。 – 4ked

関連する問題