The request is executed normally but the js syntax error is Uncaught (in promise) TypeError Cannot read properties of undefined (reading ‘code’)

During the development process, it was found that the front-end request was executed normally, the interface function was normal and the data was returned normally, but js still reported a syntax error Uncaught (in [promise] ) TypeError: Cannot read properties of undefined (reading ‘code’)
Reason: export method after custom interceptor When you forget to return the promise object, it
is as follows:
The correct way to deal with it is to requestreturn the promise object, and the place where the method is called will be executed asynchronously, and no syntax error will be prompted.

Leave a Comment

Your email address will not be published. Required fields are marked *