Can't get promisify working with a basic example
See original GitHub issueI’m really hoping that I’ve just continually missed something obvious here, but after trying for hours to use promisify, I’ve distilled things down to a VERY simple example that only logs “running” and never “then”. What have I missed or is this a bug?
<html>
<head>
<script src="http://requirejs.org/docs/release/2.1.2/minified/require.js"></script>
</head>
<body>
<script>
require(['https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.10.1/bluebird.js'], function( Promise ) {
var initServer = Promise.promisify( function( foobar ) {
console.log( 'running' );
return true;
} )( { foobar: 1 } ).then( function( ) {
console.log( 'then' );
});
});
</script>
</body>
</html>
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
I'm trying to use the Bluebird's method Promisify and it's not ...
Bluebird's promisify () only works with node-style functions that take a callback as their last argument where that callback takes two ...
Read more >Promisification - The Modern JavaScript Tutorial
“Promisification” is a long word for a simple transformation. It's the conversion of a function that accepts a callback into a function that ......
Read more >Node.js util.promisify() Method - GeeksforGeeks
The util.promisify() method defines in utilities module of Node.js standard library. It is basically used to convert a method that returns ...
Read more >Resolving the JavaScript Promise Error "TypeError: Cannot ...
Working with JavaScript Promise comes with its own array of errors, and a popular one is TypeError: Cannot read property 'then' of undefined ......
Read more >JavaScript Promise Tutorial – How to Resolve or Reject ...
A rejected promise is returned for any kind of errors. We will be using this function in several examples from now on to...
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
haha. That fs example is why I’ve not understood sooner. Not ONE example out there is standalone (and thus clear). Thank you though, I did figure it out and am leaving it here for anyone else that might find it useful:
Here is a Gist that covers both approaches with errors: https://gist.github.com/rainabba/b83eed7f6317e5e7d945
for illustration purposes, don’t actually do this, use
.promisifyAll()
instead