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?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3fcde-2c4aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3fcde-2c4aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?