Tuesday, 2 May 2017

I can't get the value of nodejs

in my console.log(info), I want to get the value of "result", but when I use console.log(info), I have a return of "Promise { }"

var info=new Promise((resolve, reject) => {

             request(options, (err, res, body) => {
                 if (body.match('success') || body.match('code="25"')) {
                     resolve("success");
                 } else {
                     reject(body);
                 }
             });
         }).then(result => {

             return result;


         }).catch(err => {
             console.log("error: " + err)
         });

console.log(info);

I would like "info == result", how can I do it? thanks



via aline5188

No comments:

Post a Comment