promise Questions

29

Solved

I have been using ES6 Promise. Ordinarily, a Promise is constructed and used like this new Promise(function(resolve, reject){ if (someCondition){ resolve(); } else { reject(); } }); But I...
Matriarch asked 1/10, 2014 at 20:40

2

Solved

this is a snippet of my template: <div class="explanation"> {{ foo() | async }} </div> this is the function: foo(): Promise<string> { return Promise.resolve('hello'); } ...
Thermit asked 20/11, 2018 at 18:11

3

Solved

Is it possible to ignore a catch and return back to the chain? promiseA() // <-- fails with 'missing' reason .then(promiseB) // <-- these are not going to run .then(promiseC) .catch(func...
Novak asked 13/4, 2016 at 11:26

11

function first(){ console.log('first') } function second(){ console.log('second') } let interval = async ()=>{ await setInterval(first,2000) await setInterval(second,2000) } interval(); Im...
Borszcz asked 5/9, 2018 at 11:40

4

Solved

I'm new to node.js and am currently trying to code array iterations. I have an array of 1,000 items - which I'd like to iterate through in blocks of 50 items at a time due to problems with server l...
Cybernetics asked 8/10, 2017 at 14:40

7

Is there a way to delay the evaluation of an array of promises using Promise.all()? Does it make sense to manually add a delay function to the end of each promise before adding them to the array? ...
Gond asked 21/11, 2017 at 18:8

24

Solved

Pattern that keep on retrying until the promise resolves (with delay and maxRetries). Pattern that keeps on retrying until the condition meets on the result (with delay and maxRetries). A memory e...
Fermanagh asked 5/7, 2016 at 22:11

8

I am using node-mysql, node-js, and Q promises. I have successfully updated, deleted, and inserted single rows using the above. As well as inserted multiple rows in a single statement in my test c...
Boart asked 28/8, 2014 at 15:2

2

Jest is throwing me the following error message -- node:internal/process/promises:245 triggerUncaughtException(err, true /* fromPromise */); ^ [UnhandledPromiseRejection: This error originated e...
Cathicathie asked 26/5, 2021 at 18:54

2

Is there another way of achieving the same behavior of scheduling a callback function on the JavaScript's message queue to be run after the current stack is empty? In other words, is there a way, b...
Ibsen asked 6/8, 2021 at 4:16

2

I want to do something like this const { Readable } = require("stream"); function generatorToStream(generator) { return new Readable({ read() { (async () => { for await (const result of ge...
Clothesbasket asked 25/2, 2019 at 13:33

9

Solved

How do I set the type of the rejection of my promise? Let's say I do: const start = (): Promise<string> => { return new Promise((resolve, reject) => { if (someCondition) { resolve('...
Laaland asked 27/4, 2018 at 22:38

3

There is a new cool feature in React — Suspense component. Currently it only officially supports components created using React.lazy function. But unofficially it well known that internally Suspens...
Counterstroke asked 17/1, 2020 at 16:57

13

Solved

Is there any harm in using async/await and .then().catch() together such as: async apiCall(params) { var results = await this.anotherCall() .then(results => { //do any results transformation...
Annabelannabela asked 6/3, 2019 at 9:27

3

Solved

I am looking for a way to create deferred object which will be resolved outside the current scope. I like deferred objects and as I see Promise.defer() in Chrome 38 returns the deferred object. Bu...
Aubert asked 11/1, 2015 at 17:2

3

I'm trying to understand node.js single threaded architecture and the eventloop to make our application more efficient. So consider this scenario where I have to make several database calls for an ...
Brisling asked 12/7, 2020 at 15:3

10

Solved

Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchronousOperation(item); return item + 1; }); ...
Arboriculture asked 19/10, 2016 at 19:39

3

Solved

I have trouble understanding the difference between putting .catch BEFORE and AFTER then in a nested promise. Alternative 1: test1Async(10).then((res) => { return test2Async(22) .then((res) ...
Creamcolored asked 2/2, 2017 at 21:59

3

Solved

I've been trying to get a conceptual understanding of why the following code doesn't catch the throw. If you remove the async keyword from the new Promise(async (resolve, ... part then it works fin...
Dispensable asked 29/3, 2017 at 3:18

8

Solved

If I have an array of urls: var urls = ['1.txt', '2.txt', '3.txt']; // these text files contain "one", "two", "three", respectively. And I want to build an object that looks like this: var text...
Copyreader asked 29/7, 2015 at 20:46

15

I'm trying to understand javascript promises better with Axios. What I pretend is to handle all errors in Request.js and only call the request function from anywhere without having to use catch(). ...
Millburn asked 22/4, 2018 at 15:45

6

Solved

I am running a forEach loop on an array and making two calls which return promises, and I want to populate an object say this.options, and then do other stuff with it. Right now I am running into t...
Nomen asked 13/7, 2016 at 21:45

6

I'm trying to wrap http.request into Promise: new Promise(function(resolve, reject) { var req = http.request({ host: '127.0.0.1', port: 4000, method: 'GET', path: '/api/v1/service' }, funct...
Janniejanos asked 22/7, 2016 at 18:59

8

Solved

I have read several articles on this subject, but it is still not clear to me if there is a difference between Promise.reject vs. throwing an error. For example, Using Promise.reject return async...
Lancelancelet asked 30/10, 2015 at 21:48

4

I use Observable.forkJoin() to handle the response after both HTTP calls finishes, but if either one of them returns an error, how can I catch that error? Observable.forkJoin( this.http.post<a...
Mischievous asked 29/6, 2018 at 14:18

© 2022 - 2025 — McMap. All rights reserved.