var p1= new Promise(function (resolve, reject) { resolve({ data: [1, 2, 3, 4], resposneCode: "00001", resposneRemark: "success" }) reject({ resposneCode: "00000", resposneRemark: "failure, experiencing network problems" , data: [2] }) }).then(function ({ data }) { return { data } }, function ({ data }) { return { data } }); p1.then(function (data) { console.log(data) }, function ({ data }) { return { data } });
In the case of reject and have the resolve, reject is not performed.
then will return to promise, two functions, a return rresolve a return to reject.