Article From:

vueThere are now two methods in the project. There is a C method, which needs to be executed after the two asynchronous requests are finished.
These two methods use the library of promise and Axios of ES6.

created() {
method: {
    _getChannelList() {
      getChannelList(this.getCookie('sender'), this.getCookie('version')).then(res => {
        // Success}).Catch (ERR => {Console.log (ERR)})},_getRecentContact () {GetRecentContact (this.getCookie ('sender')).Then (RES => {/ / / success}).Catch (ERR =>){Console.log (ERR)})},C () {/ / we need to execute the above two methods when the request is completed.}}

Answer 0:

axiosMultiple concurrent requests can be executed

function getUserAccount() {
  return axios.get('/user/12345');

function getUserPermissions() {
  return axios.get('/user/12345/permissions');

axios.all([getUserAccount(), getUserPermissions()])
  .then(axios.spread(function (acct, perms) {
    // The two requests are now executed}))

Answer 1:

You can use Promise.all to control the process

Answer 2:

It can be easily done with Promise:

Promise.all([this._getChannelList(), this._getRecentContact()])
  .then(() => {

Now that I have been invited, I would like to recommend my lecture: Promise’s N usage, and explain the common usage of Promise.

Leave a Reply

Your email address will not be published. Required fields are marked *