Last active
August 29, 2015 14:04
-
-
Save hajovsky/eceead443d4b51b804f2 to your computer and use it in GitHub Desktop.
yieldable superagent
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
var request = require('superagent'); | |
var yieldable = require('yieldable'); | |
var co = require('co'); | |
yieldable([ | |
request.Request | |
]); | |
co(function *() { | |
var ua = 'Mozilla/1.0'; | |
var response = yield request | |
.post('http://httpbin.org/post') | |
.send({lorem: 'ipsum'}) | |
.set('User-Agent', ua) | |
.y$end(); // <– new yieldable method with "y$" prefix | |
console.log(response.body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment