Secondary encapsulation of axios, can request to the interface, but print res.data as undefined in .then

1. Specific configuration code

clipboard.png

add that it is not res that returns data for undefined, but data for data,

add:

  • ajax request has been triggered
  • The value data returned by
  • ajax is undefined
Mar.18,2021

you can't see the problem at first glance. It is recommended to check it like this:

  1. check to see if the ajax request is triggered
  2. take a look at the returned result of ajax request
  3. use catch to catch errors and view error messages

in addition, axios itself returns Promise,. You don't need to wrap a Promise and put it on the outside.

Why

transformResponse did not return a value?

Menu