Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created June 30, 2015 04:24
Show Gist options
  • Save ajcrites/f36d2e4b4928c1a08764 to your computer and use it in GitHub Desktop.
Save ajcrites/f36d2e4b4928c1a08764 to your computer and use it in GitHub Desktop.
import request from "request-promise";
import {readFile, writeFile} from "mz/fs";
import co from "co";
let uri = "http://localhost:8917";
co(function* () {
let body = yield request.get({uri});
yield writeFile(__dirname + "/foo", body);
let contents = yield readFile(__dirname + "/foo");
yield writeFile(__dirname + "/bar", contents.toString().split("").reverse().join(""));
let res = yield request({uri, method: "POST"});
return res;
})
.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