async/await handles multiple asynchronous operations

tags: js

/*
  async/await handles multiple asynchronous tasks
*/
axios.defaults.baseURL = 'http://localhost:3000';

async function queryData() {
         var info = await axios.get('async1');//Get the info data from async1 first
         var ret = await axios.get('async2?info=' + info.data);//The parameter includes the first info data
    return ret.data;
}

queryData().then(function(data){
    console.log(data)
})

Intelligent Recommendation

Js handles asynchronous callback, Promise, async+await three ways

A brief introduction to the three ways of javascript processing asynchronous Can be copied and run directly with Node to see the results  ...

async/await-6. Use Promise.all() to make multiple await operations in parallel

async/await-6. Use Promise.all() to make multiple await operations in parallel...

async/await-5. Correctly handle multiple await operations

async/await-5. Correctly handle multiple await operations 1. Two requests serially process multiple await operations, call the asynchronous operation first, and then process the asynchronous result 2....

Async / AWAIT implements asynchronous interface request operations to synchronization

Async / await is still based on Promise, but it is more convenient to use natural habits in use. The async function is internally executed. Await is equivalent to .then. Call asynchronous execution ou...

Use async / await asynchronous processing multiple images simultaneously uploaded to the server

Encountered such a demand on the project, is the question of feedback, allowing the user to upload pictures. Because it is a multi-picture simultaneous uploads, and taking into account the user might ...

More Recommendation

Promise.all handles multiple asynchronous requests

Use promise.all to ensure the return order of multiple asynchronous requests talk is cheap, show the code!...

Async function handles asynchronous requests

In the promise we handle the way in which asynchronous data is interdependent, using chained calls. Although it has been optimized much more than the callback function, there is no synchronization cod...

Es6 async/awite handles asynchronous

What is async/await async/await can be used to write asynchronous code async/await is based on Promise async/await makes asynchronous code open like synchronous code, cleaner and clearer async Async i...

About using Async, AWAIT, Promise.all to solve multiple asynchronous methods when calling multiple asynchronous methods

1. Description of the problem encountered When using ASYNC and AWAIT, the asynchronous function is called inside. The printing object D data is complete after receiving the returned object D, but the ...

Asynchronous artifact async-await

Regarding asynchronous processing, the ES5 callback made us fall into hell. The ES6 Promise took us out of the magic barrier. Finally, ES7's async-await took us to the light. Learn about async-await t...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top