When calling a function in the background of an axios request, how do I make the request complete and continue to execute?

problem description

the axios request is encapsulated in a function. When calling with other functions, it is always executed directly before the background request is executed because it is an asynchronous operation. As a result, the correct data cannot be obtained. Please ask your predecessors how to solve the problem. Vue rookie, thank you very much.

the environmental background of the problems and what methods you have tried

try to use aysnc and await, as shown below, but it is still unsuccessful

related codes

/ / Please paste the code text below (do not replace the code with pictures)

aysnc checkLogin () {
        if (localStorage.getItem("access_token")){
          //access_token
          var postData = qs.stringify({
            "access_token": localStorage.getItem("access_token"),
            "refresh_token": localStorage.getItem("refresh_token"),
            "username": localStorage.getItem("username")
          })
          axios({
            method: "POST",
            url: globalVar.remoteUrl + "/LoginCheck",
            data: postData,
            responseType: "json",
            headers: {"Content-Type": "application/x-www-form-urlencoded"}
          }).then((response) => {
            if (response.data.code === 200){
              //
              this.$toast.success("")
            }else if(response.data.code === 201){
              // access_tokenrefresh_token
              this.$toast.success("access_token")
            }else if(response.data.code === 404){
              // access_tokenrefresh_token
              this.$toast.error("")
              console.log("111")
            }
          })
          }else {
          this.$toast.error("")
        }
      },
      async Login () {
        await this.checkLogin();
        console.log("222")
      },

what result do you expect? What is the error message actually seen?

I think
console.log ("111")
then
console.log
the result is always negative

.
May.05,2022

use co convenience points:


async/await

  checkLogin() {
        if (!localStorage.getItem("access_token")) {
            return Promise.reject();
        }
        //access_token
        var postData = qs.stringify({
            access_token: localStorage.getItem("access_token"),
            refresh_token: localStorage.getItem("refresh_token"),
            username: localStorage.getItem("username")
        });
        return axios({
            method: "POST",
            url: globalVar.remoteUrl + "/LoginCheck",
            data: postData,
            responseType: "json",
            headers: { "Content-Type": "application/x-www-form-urlencoded" }
        });
    },
    async Login() {
            let response = await this.checkLogin().catch(err=>{
                this.$toast.error("");
            });
         
            if (response&&response.data.code === 200) {
                //
                this.$toast.success("");
            } else if (response&&response.data.code === 201) {
                // access_tokenrefresh_token
                this.$toast.success("access_token");
            } else if (response&&response.data.code === 404) {
                // access_tokenrefresh_token
                this.$toast.error("");
                console.log("111");
            }
            console.log("222");
       
    }
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-1b44982-40cb0.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-1b44982-40cb0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?