1

example

reponse of my request is so slowly it will not perform request at same time..

axios
    .all([        
        axios.get('/api/completed'),
        axios.get('/api/newproject'),
        axios.get('/api/onprogress'),
        axios.get('/api/onsale'),
        axios.get('/api/project_summary'),
    ]) 
    .then(axios.spread((onprogress, onsale,completed,project_summary,newproject) => {   
     // output of req.
    
    }));
julianstark999
  • 3,450
  • 1
  • 27
  • 41
Not a Pro
  • 163
  • 2
  • 12

1 Answers1

0

This depends probably on your backend. As seen in your screenshot, the browser starts all requests at once. It seems that your backend can only handle one request at a time and therefor sends the responses one after the other.

If you have a Node.js backend (just a guess, Node.js is single-threaded by default) you can check if you use some sync I/O operations and replace them with async operations. This can help that your backend processes run more "in parallel" and reduce the overall time.

CimChd
  • 191
  • 6
  • I'm using laravel and vue.js how can I make this on the backend? – Not a Pro Feb 19 '21 at 06:50
  • I think Laravel has a throttle mechanism where you can protect your api to be misused and limit the parallel usage, Maybe the is something configured that prevents your api calls from being processed parallel. See: https://laravel.com/docs/5.6/routing#rate-limiting – CimChd Feb 19 '21 at 07:10