0

代码

// my.middleware.js
module.export = {
    name: "MyMiddleware",

    localAction(next, action) {
        return function(ctx) {
            // Change context properties or something
            return next(ctx)
                .then(res => {
                    // Do something with the response
                    return res;
                })
                .catch(err => {
                    // Handle error or throw further
                    throw err;
                });
        }
    }
}

中间件出错

 [2021-12-06T17:35:15.638Z] ERROR local-app/V1.API:    Request error! TypeError : Cannot read property 'catch' of undefined
 TypeError: Cannot read property 'catch' of undefined

如何克服这个错误?

4

0 回答 0