Skip to content

Instantly share code, notes, and snippets.

Avatar

Johnny Wang johnny-y-wang

View GitHub Profile
@johnny-y-wang
johnny-y-wang / readme.md
Created Mar 6, 2019
Calculate total cost of the most recent 50 Uber trips
View readme.md
(async function () {
(fetch("https://riders.uber.com/api/getTripsForClient", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9","content-type":"application/json","x-csrf-token":"*INSERT YOUR TOKEN HERE*"},"referrer":"https://riders.uber.com/trips?offset=0","referrerPolicy":"no-referrer-when-downgrade","body":"{\"limit\":50,\"offset\":\"0\",\"range\":{\"fromTime\":null,\"toTime\":null}}","method":"POST","mode":"cors"})).then(function(response) {
return response.json();
}).then(function(data) {
const trips = data.data.trips.trips;
const totalCosts = trips.reduce((acc, trip) => {
return Number(trip.clientFare) + (Number(acc) || 0)
})
console.log(totalCosts)
});
View gist:12d48f49ac39ecc419ec54fc6b1578cd
### Keybase proof
I hereby claim:
* I am johnny-y-wang on github.
* I am johnnyw (https://keybase.io/johnnyw) on keybase.
* I have a public key ASAcQXCkjdZJj3uT0r_Izzwg7ZxGgUtfmOABxf-d4mAAZQo
To claim this, I am signing this object:
You can’t perform that action at this time.