更新时间:2023-12-02 20:56:04
事实证明,回调函数的第一个参数始终是错误的,因此,如果我们从异步操作中获得某些结果,我们应该将null
作为第一个参数传递给callback
,例如就我而言,我应该有这个:
It turns out that the first argument of callback function is always error, thus if we have the some result to pass from asynchronous action we should pass null
as the first argument to callback
, e.g. in my case I should have this:
fetch(settings.url, settings)
.then(function (r) {
callback(null, {data: r});
}).catch(callback);