Skip to content
Advertisement

Tag: es6-promise

Why doesn’t .then() need the async keyword when used (similar to await)? How does Javascript know it’s an asynchronous operation?

I’m starting to learn asynchronous Javascript and I’m really confused. To be honest, the async/await approach seems very logical to me. We need to let the runtime know we’re doing an asynchronous operation so it can handle it accordingly. But why don’t we need to do the same when using the .then() method? I mean, if Javascript was already able

Javascript Promises catch block not working?

I am trying to make a function that calls promises synchronously so that if any of them return false the execution stops and returns the reject object with the reason why the promise returned false. Right now I am getting the error: UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by

Is Observables is also executed in the same way like promises in the call stack? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I’m a complete novice when it comes to Javascript. Please assist me in comprehending the concepts of Observables. Do Observables

Throwing errors in async await functions and catching from where it’s called

How can we catch error from an async await function from where it’s called? For example, I have a React component which calls a async-await function imported from another module. When I use Promise.reject(“An unknown has occurred”); in that function, so in my React component why can’t I get the error in asyncAwaitFunction.catch((e)=>console.log(e))? I even tried throw “An unknown occured”,

Alternative for Promise.allSettled

I am currently using Promise.allSettled to wait for all my promises to finish(irrespective of whether they resolve or get rejected). Since my project is compliant to Node v12.3.1 I am unable to use this? What other simple alternatives can I use. Sample code: Note: Promise.allSettled is available from Node version >12.9. Adding shims is also not an option. Answer There’s

Advertisement