From 50dd179b2207197c3a302dd29f8e17f3417158b1 Mon Sep 17 00:00:00 2001 From: aminamos <26092352+aminamos@users.noreply.github.com> Date: Tue, 7 Apr 2020 08:26:58 -0700 Subject: [PATCH] creating.mjs --- src/creating.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/creating.mjs b/src/creating.mjs index 8c93a9f..dce5291 100644 --- a/src/creating.mjs +++ b/src/creating.mjs @@ -64,6 +64,8 @@ export function allPromises(){ let userTypes = axios.get("http://localhost:3000/userTypes") let addressTypes = axios.get("http://localhost:3000/addressTypes") + // wait until all promises + // fulfilled or one is rejected Promise.all([categories, statuses, userTypes, addressTypes]) .then(([cat, stat, type, address]) => { setText(""); @@ -82,6 +84,8 @@ export function allSettled(){ let userTypes = axios.get("http://localhost:3000/userTypes") let addressTypes = axios.get("http://localhost:3000/addressTypes") + // wait until all are + // fulfilled or rejected Promise.allSettled([categories, statuses, userTypes, addressTypes]) .then((values) => { let results = values.map(v => { @@ -101,6 +105,7 @@ export function race(){ let users = axios.get("http://localhost:3000/users") let backup = axios.get("http://localhost:3001/backup") + // return fastest promise Promise.race([users, backup]) .then(users => setText(JSON.stringify(users.data))) .catch(error => setText(error))