Questions tagged [promise]
Promises are a tactic for deferred computing, suitable for several styles of concurrency: thread and event loop concurrency for local computation, and both synchronous and asynchronous remote messaging. A promise represents the eventual result of an asynchronous operation. The primary way of working with promises is through a method which registers transformations from the promise's eventual value or failure reason to a new promise.
promise
22,703
questions
-1
votes
2
answers
37
views
Immediate promise chain not executing as expected? [duplicate]
function foo(num) {
return new Promise((resolve) => console.log(num));
}
foo(1).then(() => {
foo(3);
});
The function foo returns an immediately resolve promise. "1" is ...
-1
votes
0
answers
22
views
How to convert JSON Object to Javascript Object? [closed]
I need to Convert JSON Object to Javascript Object , I created a promise and returned the res
The output in browser is like
{
"students": [
{ "name": "Ahmed", &...
1
vote
1
answer
66
views
How do I avoid .then or repeated await when chaining promises in TypeScript?
I wrote some code to wrap the Playwright Page to simplify a few operations. In one of my operations, I wanted to do something like typing and tabbing (this simulates the user behaviour better even if ...
-2
votes
0
answers
23
views
TypeError: undefined is not iterable (cannot read property Symbol) [closed]
I want to wait all async tasks complete -> TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
let status = []
const promises = files.forEach(async (file) => {
...
0
votes
1
answer
63
views
Consider the last promise in a chain for Resolve.all
I want to export HTML content from Confluence pages. Those can contain <img> tags with src attributes that are just usual hyperlinks. Since I want to export those as well I decided to replace ...
0
votes
1
answer
24
views
How to make promise wait in Dynamics CRM while retrieving user details from Xrm.WebApi.online.retrieveRecord?
I am working on a Dynamics 365 project where I need to compare the logged-in user's Azure AD ID with a value from a form field and display an icon based on the comparison result. My code attempts to ...
0
votes
1
answer
23
views
Create a dynamic react component using portal and promise
Call a modal or drawer from anywhere in my react app using simple a function.
I have made this work by using the root.render, but the problem with root.render they cannot found any of my previous ...
-3
votes
0
answers
36
views
Fetch Api Call - JavaScript [duplicate]
How to use sync and await during fetch call in Javascript.
I have a separate JS file like 'APIService.js' which used fetch api to external Url.
function APIService(){
this.getData = asyn function(...
0
votes
0
answers
59
views
Unclear about callback as a promise [closed]
My boss just mopped the floor with me for being overly verbose and complicated in creating asynchronous code. The point of the code is to create a chain of sequential promises where one promise ...
3
votes
1
answer
66
views
How to elegantly manage AbortSignal event listeners when implementing abortable APIs?
Consider this simple example, probably a function you wrote a couple of times, but now abortable:
/**
*
* @param {number} delay
* @param {AbortSignal} [abortSignal]
* @returns {Promise<void&...
-1
votes
0
answers
76
views
Promise.All() executing but resolving Promises immediately without waiting for responses
I am trying to execute some tasks in parallel (literally, spread over multiple threads and CPU cores) via firing them off using Promise.All(), which then calls a function that sets them off to work ...
0
votes
2
answers
136
views
React Component - wait for prior promise method (fetch) to reach its finally {} block (cancelled using AbortController) before starting a new promise
I have a React component with 3 buttons representing 3 choices the user can make.
If the user clicks a button and then another button I cancel the previous HTTP request using AbortController.signal....
0
votes
4
answers
84
views
What functions are passed to the Promise when awaiting in javascript?
Consider the following code, which awaits a Promise:
async function handleSubmit() {
try {
await submitForm(answer);
} catch (err) {
console.log('Error')
}
}
function ...
0
votes
3
answers
57
views
Async and Multiple Awaits | Call Stack suspension
I am working with the promises and async function. The thing I got to know that inside the async function if there is a await out JS engine will suspend the ongoing call stack's function calls and ...
0
votes
1
answer
26
views
What's called exactly when a promise executor calls the resolve function before you attach a resolve function with 'then'?
I swear nothing in this language makes sense. The promise executor is run immediately, and in this case it calls the resolve function, except a resolve handler hasn't been attached yet:
// FLOW STARTS ...