/** * basic usage of bluebird */ var Promise = require("bluebird"); //defining an async function var clAsync = function () { var P = new Promise(function (resolve, reject) { console.log('Write from function'); resolve('ok'); reject('not ok'); }); /* { "isFulfilled": true, "isRejected": false, "fulfillmentValue": "ok" } */ console.log(JSON.stringify(P, null, 2)); return P; }; console.log(JSON.stringify(clAsync, null, 2)); //undefined //executing promisified function clAsync() and adding new callback with then method clAsync() .then(function (returnedVal) { console.log('THEN 1 - fulfillmentValue= ' + returnedVal); return {one: 1, two: 'drugi'}; //returning to next then }) .then(function (returnedVal) { console.logs('THEN 2 - fulfillmentValue= ' + returnedVal.one + returnedVal.two); // return new Error('Namjerna greška'); --doesn't work throw new Error('Namjerna greška', 'someFile.js', 152); }) //catch type errors .catch(TypeError, function (e) { console.error(e.stack); // console.error(e.message); }) //catch all other errors .catch(function (e) { console.error(e.message); // console.error(e.stack); });
$ps -aux | grep node (list all node processes) sasa 890 0.5 0.5 11797020 84092 ? Ssl 2024 1533:41 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js sasa 903 0.7 0.5 1331320 83964 ? Ssl 2024 2174:30 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js sasa 929 0.3 0.4 1302328 70600 ? Ssl 2024 1025:53 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js sasa 943 0.3 0.4 1303368 69676 ? Ssl 2024 1004:13 node /home/sasa/dex8/dex8-kiosk/server/index.js sasa 980 0.5 0.5 11803104 91500 ? Ssl 2024 1650:11 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js sasa 981 0.5 0.6 1153712 109260 ? Ssl 2024 1704:21 node /home/sasa/voovuu/voovuu-api/starter.js sasa 1039 0.8 1.9 12081192 313488 ? Ssl 2024 2509:45 node /home/sasa/voovuu/voovuu-pub/server/index.js www-data 1252914 0.0 0.0 2608 536 ? S 00:25 0:00 sh -c ps -aux | grep node www-data 1252916 0.0 0.0 3304 732 ? S 00:25 0:00 grep node sasa 1788108 0.4 0.5 11804596 90448 ? Ssl Mar16 235:45 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index. sasa 1790865 0.7 0.6 11824712 104180 ? Ssl Jan30 870:35 node /home/sasa/dex8/dex8-www/server/index.js sasa 1791369 0.7 0.8 11789608 139260 ? Ssl Jan30 871:58 node /home/sasa/dex8/dex8-api/starter.js sasa 2044488 0.3 0.4 1300372 69656 ? Ssl 2024 872:43 node /home/sasa/dex8/dex8-panel/server/index.js sasa 2574087 0.3 0.4 11795224 79808 ? Ssl 2024 957:23 node /home/sasa/@mikosoft/dodo-examples/server/index.js sasa 3598766 0.3 0.4 1100892 65632 ? Ssl 2024 590:08 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598767 0.3 0.4 22280304 80608 ? Ssl 2024 600:19 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598774 0.3 0.4 1100896 65792 ? Ssl 2024 592:27 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598775 0.3 0.4 1101408 66768 ? Ssl 2024 593:53 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598802 0.6 1.0 22350028 179296 ? Ssl 2024 1084:36 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598803 0.3 0.4 1100640 65624 ? Ssl 2024 590:27 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598851 0.3 0.4 1102180 67148 ? Ssl 2024 590:51 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598853 0.3 0.4 1101412 66836 ? Ssl 2024 590:34 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598925 0.3 0.5 1329408 82532 ? Ssl 2024 614:57 node /home/sasa/dex8/dex8-worker/starter.js sasa 3598927 0.3 0.3 1296140 65228 ? Ssl 2024 591:28 node /home/sasa/dex8/dex8-worker/starter.js