Using bluebird to promisify Node's http.request?
See original GitHub issueCan anyone help me promisify Node’s http.request with bluebird?
Here is my try:
var http = require('http');
var Promise = require('./framework/libraries/bluebird');
var PromiseRequest = Promise.promisify(http.request);
var myRequest = PromiseRequest({
method: 'GET',
host: 'nodejs.org',
port: 80,
path: '/',
}).then(function(value) {
console.log('value:', value);
});
console.log('myRequest:', myRequest);
Unfortunately this code never completes and the ‘then’ callback is never executed.
@petkaantonov - love the library! Especially how performant it is!
Issue Analytics
- State:
- Created 9 years ago
- Comments:7
Top Results From Across the Web
Promise.promisify
Returns a function that will wrap the given nodeFunction . Instead of taking a callback, the returned function will return a promise whose...
Read more >node.js - NodeJS Promisify an existing API with BlueBird
Start off by promisifying a single function var MyModule = new(require('../lib/MyModule')); var Promise = require("bluebird"); var ...
Read more >Bluebird NPM: Bluebird JS Promise with Example
Bluebird JS is a fully-featured Promise library for JavaScript. The strongest feature of Bluebird is that it allows you to “promisify” other ...
Read more >Using Promises in Node.js Applications using Bluebird
The promise object accepts callbacks that get invoked when the operation either succeeds or, fails. Dependent asynchronous operations can be ...
Read more >squarecapadmin/request-promise
The world-famous HTTP client "Request" now Promises/A+ compliant. Powered by Bluebird. Bluebird and Request are pretty awesome, but I found myself using the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@benjamingr LOL, I literally was writing this when your response came in on my email:
Thank you!
@benjamingr thanks! You sent me in the right direction. Can you take a second to review this code and let me know if I am doing anything weird or incorrectly?