ACArtur Carvalhoinarturcarvalho.hashnode.dev·Apr 21, 2023 · 3 min readJavaScript Promise.all, Promise.race and Promise.allSettledThe following article will explain how to handle several Promises concurrently. Although the Promise object contains several methods to deal with handling multiple Promises at the same time (see topics below), there is another way to do this: const r...00
ACArtur Carvalhoinarturcarvalho.hashnode.dev·Apr 20, 2023 · 1 min readJavaScript Promise.resolve and Promise.rejectRunning Promise.resolve(value) is almost the same as the resolve method in a Promise. And running Promise.reject(value) is almost the same as the reject method in a Promise. Let's see the differences in the next section. Promise.resolve vs resolve (a...00
ACArtur Carvalhoinarturcarvalho.hashnode.dev·Apr 20, 2023 · 3 min readJavaScript Promises states and rulesPromises states A promise can be in 1 of 3 states: Fulfilled: The resolve function was called. Rejected: The reject function was called. Pending: The resolve or reject functions were not called yet. Settled: The promise is settled if it's not pendin...00
ACArtur Carvalhoinarturcarvalho.hashnode.dev·Apr 19, 2023 · 4 min readJavaScript Promise error handling with catch and finallyLet's see how to handle errors in JavaScript Promises. You might think you can put a try/catch around a Promise: try { const p = new Promise((resolve, reject) => { console.log("I think I'm about to throw up!"); throw new Error('boom'); })...00
ACArtur Carvalhoinarturcarvalho.hashnode.dev·Apr 18, 2023 · 2 min readJavaScript Promise chainingImagine you want to: Request a user from a server (and wait for the user information). Get the user's friends from the server (and wait for the information). Show the user name and the user friends' names at the same time. This is how you do it ...00