我在我的应用中使用p
,我使用babel将我的代码编译成es5。但是,我总是得到这个警告,并且我已经检查过Promise的每个部分都有bluebird
值。
这是我的代码:
return
错误消息的详细信息:
Promise.promisifyAll(fs);
use.login().then((result) => {
console.log(result);
doSomething('../test.png');
});
function doSomething(filepath) {
return fs.readFileAsync(filepath).then((bufs) => (
doPost(url, bufs, filepath)
.then((res) => (
res.error ? Promise.reject(res.error) : Promise.resolve(res))
)
)).catch((err) => {
console.error(err);
return err;
});
}
function doPost(url, bufs = null, filepath = null) {
return new Promise((resolve, reject) => (
unirest.post(url)
.headers(config.Headers)
.timeout(120000)
.field(bufs)
.attach('files', filepath)
.end((res) => (
res.error ? reject(res.error) : resolve(res)
))
));
}
答案 0 :(得分:0)
感谢@Bergi我没有检查我呼叫doSomething
的保证堆栈,所以在修改我的代码后警告消失了
use.login().then((result) => {
console.log(result);
doSomething('../test.png');
return null; // Add this line to make promise return anything, then the warning gone
});