Encapsulated axios, request status is 200, but both then and catch methods are in

my_axios[method] = function (uri, data, config) {
    return new Promise(function (resolve, reject) {
      instance[method](uri, data, config)
        .then((respone) => {
          console.log("")
          if (respone.status) {
            resolve(respone);
          } else {
            if (respone.msg.match(/[0-9]+/)[0] === "302") {
              Vue.$message.error("")
              Vue.$router.push("/login")
            }
            resolve(respone);
          }
        })
        .catch((response) => {
          console.log("")
          Vue.$message.error("")
          reject(response)
        })
    })
  }

clipboard.png

Mar.14,2021

"success" can be printed, so your instance [method] this promise is resolve.

I guess: your code, resolve (.) after console.log. I made a mistake before

.

it is recommended that you print out the response in catch on the console to see if there are any errors in the logic in the above then (for example, the response in the above then is actually undefined)


emmm, this is how we seal it

  

'302' remove quotation marks

Menu