Skip to content

Instantly share code, notes, and snippets.

@andywarr

andywarr/uber-dash.js

Last active May 30, 2016
Embed
What would you like to do?
Cancel an Uber
var https = require('https');
// For information about Uber http status codes see: https://developer.uber.com/docs/api-reference
const successfully_cancelled_uber_status_code = 204;
// For information about Uber tokens see: https://developer.uber.com/docs/authentication
const token = process.env.TOKEN;
function cancelUber(event, context) {
var headers = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
};
var options = {
'host': 'api.uber.com',
'path': '/v1/requests/cancel',
'method': 'DELETE',
'headers': headers
};
var req = https.request(options, function(res) {
var body = '';
res.on('data', function (chunk) {
body += chunk;
});
res.on('end', function () {
// Successfully cancelled Uber
if (res.statusCode === successfully_cancelled_uber_status_code) {
console.log('Uber cancelled. Status code: ' + res.statusCode);
}
context.done();
});
});
req.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.