Monday, 1 May 2017

Bad Request error in uber api

I've been trying to get the uber price estimates endpoint working, but I'm stuck on an error that leads me to a blank page saying, "Bad Request." The console also says "callback not a function" but I can't seem to find out what is wrong.

My route:

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

Any help is appreciated.



via Max Goeke

No comments:

Post a Comment