In Vue, in an axios request, send another network request, and then how to wait for the child request to return the result in the first parent request

ashamed, ashamed, the same problem, slightly change the conditions, suffering, can always abuse me over and over again

Let"s start with the code, which is the processing in the parent request, where the parent request waits for the return result of the child request, and then executes the following

.
.then( async (response) => {
  if (response.data.code === "200") {
    console.log("ID:", response.data.msg);
    const id = response.data.msg;
    Notice.success({
      title: ":",
      desc: ""
    });
    router.push({path: "/ai/" + id + ""});
  } else if (response.data.code === "402") {
      //axios
    const result = await AuthenticationApi.getToken();
    console.log("write_article result:", result);
    if (result) {
      this.write_article(ArticleTitle, ArticleContent, ArticleLabel, origin_link)
    } else {
      console.log(" write_article ?????? what the fuck ???????")
    }
  } else {
    console.log("write_article else info :", response)
  }
})

the result I want is to wait for the AuthenticationApi.getToken () child request to return true, and then re-execute the parent request, but the result is

clipboard.png

how to solve it? Ask for help, thank you prawns

Jun.30,2022

AuthenticationApi.getToken (); is your method asynchronous (async? Promise? )?

eg:

function resolveAfter2Seconds(x) { 
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x);
    }, 2000);
  });
}

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // 10
}
f1();
function resolveAfter2Seconds(x) { 
  setTimeout(() => {
      resolve(x);
    }, 2000);
}

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // undefined
}
f1();
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-1bd4fcd-30f35.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-1bd4fcd-30f35.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?