Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created June 30, 2015 03:50
Show Gist options
  • Save ajcrites/d721ba1e70d8f5db5941 to your computer and use it in GitHub Desktop.
Save ajcrites/d721ba1e70d8f5db5941 to your computer and use it in GitHub Desktop.
import request from "request-promise";
import {readFile, writeFile} from "mz/fs";
let uri = "http://localhost:8917";
request.get({uri})
.then(body => writeFile(__dirname + "/foo", body))
.then(() => readFile(__dirname + "/foo"))
.then(contents => writeFile(__dirname + "/bar", contents.toString().split("").reverse().join("")))
.then(() => request({uri, method: "POST"}))
.then(res => console.log("posted file"))
.catch(err => console.error(err.stack));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment