Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialThomas Dimnet
Python Development Techdegree Graduate 43,629 PointsManage multiple asynchronous calls with Express
Hi there,
I understand the id of the next middleware and when to use it. But I am wondering how to work with multiple asynchronous calls with express (either when building an express rest api or when rendering templates directly with express and pug).
Do we use promises and new ES7 methods like async/await or is there some other solutions?
Thanks!
Thomas.
1 Answer
d4rk5un
2,771 PointsHi Thomas
I believe you can use both promises and callback functions to do async calls.
But using promises is a lot cleaner and can prevent calling functions more than once, since the promise will return and will not execute the rest.
I suggest you have a look at axios, it is fantastic package.
https://www.npmjs.com/package/axios
I hope this helps.
Good luck
K.