Created
June 30, 2015 04:24
-
-
Save ajcrites/f36d2e4b4928c1a08764 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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