I am new to promises as I am trying to get some objects to show there actual values on a webpage. Instead I am just getting a bunch of [object Promise] instead This is the code I have so far: What I tried I tried reading the firefox promise.resolve method as that seems like what I was looking for: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve
Tag: promise
How can I put elements in Promise.all() array conditionally?
The code below is what I wrote. I know ‘await’ keyword shouldn’t be in for-loop well. So, I tried like this but the ‘result’ contains every elements from ‘userBooks’ and that’s not what I wanted. Please help this poor newbie😥 Answer Your condition to add the promise into array lies inside the promise result. It is not possible to add
Does catch block not get executed if ‘onRejected’ function is provided for ‘then’ block in a Promise?
Newbie in Promises here. The documentation (as in the below image) tells it internally calls the onRejected function of catch block itself. So is there any use of having a catch block in a Promise if then is being provided with both the functions? I tried throwing an error using throw ‘error’ and even Promise.reject(‘error’) in the then block neither
await js async function (promise) inside a go function
I am looking to integrate indexdb in a wasm based app. How do you “await” in a go function a promise from a js function. Here is the example and in go Async callbacks are fine too. LE: one bad solution would be to create a go routine with an infinite loop waiting until a DOM variable exists like global.solution+ID
What is the relationship, if any, between the “executor” and the function passed to the then() method? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question The “executor” function I am referring to: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise#parameters And the then() method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then Seems like there is some overlap between their meaning or purpose. In
Cannot finish a race with timer in RxJS
Code above will output 2. If I have an action that I try to repeat until condition is met but ignore it if it takes too long, then I take an approach in this answer https://stackoverflow.com/a/51644077 The problem is that race never finishes with the shortest function. The longActionObservable repeats until the condition is met and empty() is called. This
Why do I get an Unhandled Promise Rejection with await Promise.all
This is the general structure of my code: I expect this to catch any rejections happening in asyncActions because they should be handled by Promise.all(), but somehow they are unhandled? The console shows the following: Why are they not handled by Promise.all() and then caught in the catch block? I also noticed that when I replace both the new Promise(…)
TypeScript / JavaScript: How to wrap a Promise object using decorator pattern
I’m attempting to wrap a TypeScript (JavaScript) Promise object with the decorator pattern because I need to add additional logic inside the Promise’s then and catch methods (not shown here). So far, it looks like this: However, as noted by the “ERROR!!” comment above, I get this build error: Type of “await” operand must either be a valid promise or
TypeScript – waiting for nested for loops to complete
I have two for loops, one nested inside the other. The first loop makes an API call. It will execute for how ever many IDs are selected by the user. I do not have the ability pass more than one ID at a time to the API. The nested loop will run for each object returned by the API and
Is this valid syntax for node/promisify async function?
I accidentally typed await(await stat(content… and it worked. Not sure if this is valid syntax, or there is a better way to do it? I’m trying to read all the files that are directories and do not match my regex. Answer ls My advice would be not to put all of your eggs in one basket. We can write an