How to pop up a dialog box before the execution of each axios request and click OK to execute the axios request?

I use

axios.interceptors.request.use(config => {
    if (getToken()) {
        config.headers["token"] = getToken() // token-- ["X-Token"]key 
      } else {
        console.log("token")
      }
      const role = store.state.permission.roleList.find(role => role.url === config.url && role.confirmFlag === _const.YES)
      console.log(role)
      if (true) {
        MessageBox("?", "", {
          confirmButtonText: "",
          cancelButtonText: "",
          type: "warning"
        }).then(() => {
          config.headers["confirmUser"] = "wcsconfirmuser"
          config.headers["confirmPwd"] = "123456"
          // Do something before request is sent
          return config
        })
      } else {
        return config
      }
})

you can"t send a request like this


solved

with Promise
service.interceptors.request.use(config => {
  return new Promise((resolve) => {
    if (getToken()) {
      config.headers['token'] = getToken() // token-- ['X-Token']key 
    } else {
      console.log('token')
    }
    const role = store.state.permission.roleList.find(role => role.url === config.url && role.confirmFlag === _const.YES)
    console.log(role)
    if (true) {
      MessageBox('?', '', {
        confirmButtonText: '',
        cancelButtonText: '',
        type: 'warning'
      }).then(() => {
        config.headers['confirmUser'] = 'wcsconfirmuser'
        config.headers['confirmPwd'] = '123456'
        console.log(JSON.stringify(config.headers))
        // Do something before request is sent
        resolve(config)
      })
    } else {
      resolve(config)
    }
  })
}, error => {
  // Do something with request error
  console.log(error) // for debug
  Promise.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-1b3c508-2bb4e.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-1b3c508-2bb4e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?