getting same response from a promise multiple times

so i have a function that would return a promise , and in case of error I have to call the same function again but the problem that whenever i call it again the same response i would get as if the …

External JS file function cannot see page function

I have an existing legacy aspx page loading an external JS file. I am adding functionality and have added an async function in a script block on the page. The external JS file has been modified to …

Async generator class stuck on infinite loop javascript

I’m trying to get the following async generator to work: class MyIterator { constructor(m) { this.collection = m; } async *[Symbol.iterator]() { for (let item of this.collection) { …

What’s the correct way to handle promise rejections so that the function exits?

Let’s say that I have this code: function doSomething() { const foo = await new Promise((resolve, reject) => { //… reject(); }).catch(error => { //I’d like to …

‘await’ call doesn’t wait

My app is trying to upload files to S3. S3 upload works fine. The problem is that after imageUpload returns, in handleSubmit(), it claims that the return value for imageUpload() is undefined. I …

Repeatedly await asynchronous post requests

I want to repeatedly do a POST request, as follows: async function request(spec){ // POST fetch(‘/spec’, { method: ‘POST’, headers: { ‘Content-Type’: ‘application/…

Javascript/Typescript Export Default Const as value from async function call

i’ve done a bunch of reading but haven’t found a working solution the closest i’ve seen is here: Export the result of async function in React please keep in mind that I want to export an object, and …

problems with an array awaiting for a function that reads from firestore

I’m trying to build a method which reads from firestore an array of elements (object): I have a service which retrieves the data from firestore, first it gets an array of document references var data …

Promise never gets resolved in javascript

I have a asyn function in which I call another function that return a promise and also calls to another async function. Here is the code: async function asyncAwaitRepeat(index) { if(index < 9) {...

Promise.all() to await the return of an object property

Inside an async function i have a loop and inside this loop i need to use await to resolve a promise from another async function. async function smallestCities(states) { const citiesInState = []; …