The vue axios get request was successful, but the returned data is in catch

simple api encapsulation

export const weChatAndSinaAcount = () => {
  return $http.get(API_HOST + "/channel/getChannelRecordNum").then(res => res.data)
}

call data and return

getWeChatAndSinaAcount () {
      weChatAndSinaAcount().then(res => {
        console.log(res)
        if (res.code === 1) {
          let data = res.data
          console.log(data)
        }
      }).catch(err => {
        console.log("Error Info:" + JSON.stringify(err))
      })
    }

return the result

Error Info:{"message":"","code":0,"data":[{"channelType":"","sumRecordNum":"0"},{"channelType":"","sumRecordNum":"0"}]}

you can see that the data request was successful (code=0 indicates success), but did not return

in then
Mar.30,2021

the encapsulation of your api is wrong.
axios does return a promise, but you then directly in api. You don't need then here.
if you want to then in api, you need to wrap it in new Promise, and then resoleve () goes out


.

export function getSystemDB () {
return new Promise ((resolve, reject) = > {

axios.get(API_HOST + '/channel/getChannelRecordNum', '')
  .then(response => {
    resolve(response.data)
  })
  .catch((error) => {
    reject(error)
  })

})
}

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-1ea4dff-1d10.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-1ea4dff-1d10.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?