Last active
August 29, 2015 13:56
Revisions
-
victorquinn revised this gist
Feb 14, 2014 . 2 changed files with 32 additions and 5 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ var Promise = require('bluebird'), express = require('express'), request = require('request'), step = require('step'); var app = express(); @@ -11,7 +12,7 @@ app.post('/test', function(req, res) { var server = app.listen(3000); function make_request_normal(callback) { request.post({ url: "http://localhost:3000/test", method: "POST", @@ -21,6 +22,25 @@ function make_request(callback) { }); } function make_request_with_step(callback) { step( function() { // noop this(null, 'test'); }, function(err, test) { request.post({ url: "http://localhost:3000/test", method: "POST", body: JSON.stringify({first_name: "Victor"}) }, this); }, function(err, response, body) { callback(null, response, body); } ); } // Works fine // make_request(function(err, response) { @@ -29,8 +49,14 @@ function make_request(callback) { // }); // Blows up? // Promise.promisify(make_request_normal)().spread(function(response, body) { // console.log(response); // console.log(body); // server.close(); // }); Promise.promisify(make_request_with_step)().spread(function(response, body) { console.log(body); server.close(); }); This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ "dependencies": { "bluebird": "~0.11.5-0", "request": "~2.33.0", "express": "~3.4.8", "step": "0.0.5" } } -
victorquinn revised this gist
Feb 14, 2014 . 2 changed files with 39 additions and 4 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,36 @@ var Promise = require('bluebird'), request = require('request'), express = require('express'); var app = express(); // test endpoint to test this request app.post('/test', function(req, res) { res.json({success: true}); }); var server = app.listen(3000); function make_request(callback) { request.post({ url: "http://localhost:3000/test", method: "POST", body: JSON.stringify({first_name: "Victor"}) }, function(err, response, body) { callback(err, response, body); }); } // Works fine // make_request(function(err, response) { // console.log(body); // server.close(); // }); // Blows up? Promise.promisify(make_request)().spread(function(response, body) { console.log(response); console.log(body); server.close(); }); This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ { "dependencies": { "bluebird": "~0.11.5-0", "request": "~2.33.0", "express": "~3.4.8" } } -
victorquinn revised this gist
Feb 14, 2014 . 3 changed files with 8 additions and 1 deletion.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ node_modules This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ var Promise = require("bluebird"); var request = require("request"); This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ { "dependencies": { "bluebird": "~1.0.4", "request": "~2.33.0" } } -
victorquinn revised this gist
Feb 14, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,2 @@ var Promise = require("bluebird"); var request = require("request"); -
victorquinn created this gist
Feb 14, 2014 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ var Promise = require("bluebird");