这个promise为什么结果是error?
bsnry 2017-10-18 05:37:58
var file = './1.txt';
function asyncFunction() {
return new Promise(function (resolve, reject) {
fs.readFile(
file, function (err, text) {
if (err) {
console.log(err);
reject("spwan some errors when read " + file);
}else{
resolve(text);
}
});
})
}
asyncFunction().then(function (text){
console.log("text:" + text);
}
).catch(function (error) {
console.log("===error===");
});
为什么结果 是catch中的那一句?