Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Nextjs: multiple dispatch and Promise

This is my code:

Promise.all([
        await dispatch(a()), 
        await dispatch(b()), 
        await dispatch(c()), 
        await dispatch(d())
    ]).then(console.log).catch(console.log);

And I get this log:

0: undefined
1: undefined
2: undefined
3: undefined

I want to get this data with Promise and I have to use await

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

the Promise.all will resolve after all async inside it are resolved so you dont need to await inside it as its an implicit await so remove the await fom inside the promis.all and check again.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading