I\'m a complete beginner in node.js
. I\'ve just read we can use .then()
function for executing several functions in particular order. I was going t
the .then() function is used for the PROMISE (so for async function ) when you need to KNOW WHEN IT'S FINISHED (and it is finished ok .. or KO ) ..so you have
MYASYNCFUNCTION().then(function(response({
//do what you want when it's finish and everything ok .. with the result
}).catch(function(error){
// it's finshed but with error
})
IN your example .. you don't have .then() function cause they're simple function .. but if you want to have it (i don't know why . they've not async stuff inside .. but you can)
so
// install it via npm install promise
var Promise = require('promise');
function one(){
var promise = new Promise(function (resolve, reject) {
resolve('one');
});
});
}
and then
one().then(function(resp){ console.log(resp) })
Hope it helps you!!