Created
April 6, 2020 12:55
-
-
Save rowlandekemezie/40ecf5ff231ab3c656153185dba96f87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Current. The request is synchronous because the former needs to finish before the later | |
const earning = await fetchLastMonthEarning(teacherInfo.teacher.teacherId, startDate, endDate); | |
const teachingHours = await fetchTeachingHours(teacherInfo.teacher.teacherId); | |
// Refactored. Ensures the request is run concurrently | |
const [ earning, teachingHours ]= await Promise.all([ | |
fetchLastMonthEarning(teacherInfo.teacher.teacherId, startDate, endDate), | |
fetchTeachingHours(teacherInfo.teacher.teacherId) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment