简体   繁体   中英

Using promises on Node.js on Windows

How does one use promises on Node.js running on Windows? For the life of me I can't seem to get any example to work...

For example something like this doesn't work:

var pinput = new Promise(
   function(fulfillPromise, breakPromise) {
     var btn = document.getElementById("button");
     var txt = document.getElementById("txt");
     btn.onclick = function() {
       fulfillPromise(txt.value);
     }
   }
);

pinput.whenOnly(function(value) { alert(value); });

Throwing in requires doesn't help either:

Promise = require('promise');

All I get is either:

ReferenceError: promise is not defined

or

Error: Cannot find module 'Promise'

And I can't seem to find the promise from the latest API either... (http://nodejs.org/docs/latest/api/)

Me be puzzled.

I believe promises were removed. See this Google Groups post for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM