Skip to main content
Filter by
Sorted by
Tagged with
-4 votes
2 answers
88 views

While reading the promise documentation I came across this statement: If it's called with the same value as the newly created promise (the promise it's "tethered to"), the promise is ...
Parminder Singh's user avatar
-1 votes
1 answer
74 views

I have a page made up of multiple forms. Each form has it's own javascript file with a validate method like so. function validateForm(){ return new Promise((resolve, reject) => { ...
geoff swartz's user avatar
  • 6,057
0 votes
0 answers
65 views

This question is about the Firefox API function: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage Why does browser.tabs.sendMessage() not seem to return a ...
mavavilj's user avatar
  • 101
-1 votes
1 answer
42 views

const cart = ["shoes","shirts","boxers","pants"] function creatOrder(cart){ return new Promise((resolve,reject)=>{ if(!ValidateCart(cart)){ ...
Grimmj0w's user avatar
0 votes
0 answers
23 views

So I am trying to build a custom react hook that fetches a value from an API and returns a string. However the issue I am running into is that it is returning a Promise and I am not sure how to ...
youssefrag's user avatar
1 vote
1 answer
180 views

Promise.try recently became available in Baseline 2025. I wanted to know how can I enable this in a TypeScript project. I'm currently using TypeScript 5.7.3 and have the following tsconfig.json: { &...
Jose A's user avatar
  • 11.4k
0 votes
0 answers
30 views

Is it defined behaviour in JavaScript to pass undefined into Promise.all like so: await Promise.all([fetchSomeData(), undefined]) What I want to achieve: execute a certain fetch only for ...
Pascal Will's user avatar
0 votes
0 answers
63 views

I've seen code like that and wonder how it works ? according to MDN Promise.allSettled expects an array of Promises but here it is passed false for one of them and seems to ignore it. Is this kind of ...
kofifus's user avatar
  • 19.7k
1 vote
1 answer
122 views

We have a item view whose contents depends on a store with is loaded from a (rather slow) api. We found that the view is mounted before the store is fully loaded which is ok but how can a store ...
theking2's user avatar
  • 3,100
0 votes
3 answers
160 views

I'm working with promises in JavaScript. I need to create three promises that each fulfill to a number. These conditions must be met: The promises must be created synchronously, not one after the ...
Evanss's user avatar
  • 22.5k
0 votes
1 answer
90 views

considering: function calculateDate(input) { var result = something_this_takes_too_much_of_the_time * input; } Repeater { count: 999 Label { text: return (new Promise(resolve =&...
Jiri Zaloudek's user avatar
0 votes
1 answer
67 views

Before i start, i like to point out i am learnging JS, so this may be trivial, but having hard time do lazy load immidiate function https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.js Example, I ...
latvian's user avatar
  • 3,245
4 votes
2 answers
93 views

I am learning microtask queue and i have a simple question. With the following code: Promise.resolve().then(()=>console.log("Resolved1 Promise")); Promise.reject().then(()=>console.log("...
Muhammad Hamza Maqsood's user avatar
0 votes
0 answers
57 views

I am new to Javascript and trying to understand how Promise really works. I understand basics of how chaining works in Promise. Is version 1 equivalent to version 2. How does version 2 works? Since &...
jay26's user avatar
  • 73
0 votes
1 answer
2k views

I set up the following to handle queries to a SQLite database. When there are no errors with the query, it performs as expected and all rows are logged to the console. When I test the functionality ...
Sam WB's user avatar
  • 193
0 votes
1 answer
73 views

I use this service class in order to get the network status: @Injectable() export class NetworkConnectionService { constructor() { } addNetworkConnectionListener() { Network.addListener('...
quma's user avatar
  • 5,797
1 vote
3 answers
121 views

I’m trying to show a loading indicator when executing a long-running task. The loader should remain visible for the entire duration of the task and then be hidden when the task completes. However, the ...
ckinte's user avatar
  • 11
2 votes
1 answer
118 views

I have a JavaScript function that generates an endless slideshow. The code works, but I'm concerned about each iteration ending in a recursive call to itself. Using developer tools, it appears that ...
Chap's user avatar
  • 3,855
-1 votes
1 answer
71 views

I am setting up a progressive Image loader (download and replacing an image with the same image in increasing quality). First I am making a cache check to see if the image is already cached. However, ...
IntiM's user avatar
  • 11
0 votes
1 answer
81 views

const p1 = new Promise((_, reject) => { reject(1); }).then((r)=>console.log(r)).catch((r)=>console.log(r)); const p2 = new Promise((resolve, _) => { resolve(10); }).then((r)=>...
bored_coffee's user avatar
0 votes
1 answer
89 views

I'm struggling to wrap my head around the javascript async/sync concepts. I've subclassed an openlayers Layer class for some custom rendering in a map. After instantiating an object of the class, I ...
Drublic's user avatar
  • 719
0 votes
0 answers
78 views

I admit I'm not a JavaScript promises expert, but this is bizarre. I'm creating an API service that's basically an Axios promise factory and importing it into Vue2 components. The simplified example ...
Nathaniel Rink's user avatar
1 vote
1 answer
138 views

I am searching whether Promise.resolve(1); includes any mcirotask queue or not? There is no .then() or .catch() handler attached to it. Only Promise.resolve(1); Example: const v = Promise.resolve(1); ...
a Learner's user avatar
  • 5,052
0 votes
2 answers
92 views

I am learning promise chaining and I stumbled upon a doubt. Consider the below promise chain - const myPromise = new Promise((resolve, reject) => { setTimeout(() => { resolve("...
Arman Lalani's user avatar
0 votes
1 answer
55 views

I was searching the proof of statement that in javascript promise handlers(then, catch) are enqueued in microtask queue after promise get resolved or rejected. First is above statement true that ...
a Learner's user avatar
  • 5,052
-1 votes
1 answer
114 views

Consider a scenario where I have two tasks - Task 1 is a callback which is set to be executed after 1 sec using setTimeout. Task 2 is a synchronous/blocking task which takes comparatively more time ...
Arman Lalani's user avatar
2 votes
1 answer
55 views

I am struggling a bit with asynchronous operations and Promises (a quite new concept to me) using FileReader. I have found a very interesting thread about it there, but can't make my script to work ...
feub's user avatar
  • 589
1 vote
1 answer
66 views

I've tried to make a Node.js program to connect to a series of TCP sockets using promises. The primary goal behind this was just a silly test: send a message, and wait for the socket to timeout or ...
Tom Luchesi's user avatar
2 votes
1 answer
111 views

I would like to be able to reason about what await will do when it is called on various kinds of values. The MDN documentation for await describes the decision procedure for that, one of the steps ...
Don Hatch's user avatar
  • 5,604
1 vote
2 answers
93 views

Consider this: const a = () => { return new Promise((resolve) => { resolve(1); }); }; const b = () => { return new Promise((resolve) => { a() .then((aR) => { ...
typed-sigterm's user avatar
1 vote
1 answer
232 views

I posted this question a couple of days ago, then removed it after I was pointed that it essentially didn't demonstrate the problem I was dealing with. Then I was asked to restore the question, but I ...
d.k's user avatar
  • 4,500
1 vote
1 answer
419 views

Here's code where the type of a promise disagrees with its resolved value: const p: Promise<number> = Promise.resolve(1); const q: Promise<string> = p.then<string>(); const r: string ...
Lucian Wischik's user avatar
1 vote
1 answer
146 views

I'm implementing a application in a web browser that has a button to toggle full screen using the Fullscreen Browser API. I had assumed that I could .then() the promise returned by requestFullscreen() ...
Bob Gilmore's user avatar
0 votes
0 answers
56 views

I have an Angular app and I am getting the contents of a json file from Google Drive. The contents is an array of 1011 customers that I want to transform into an object. However the reduce function ...
Konstantinos Papakonstantinou's user avatar
1 vote
1 answer
62 views

I created a Weather class with methods used to fetch geographical weather info from openweather API. In my Angular component, I am trying to call the .getWeather(cityName) which gets coordinates for a ...
drewhouses's user avatar
0 votes
0 answers
35 views

With node v18, I am trying to loop over an array of directories, and check if that directory is currently on the main git branch. However the await doesn't seem to be doing anything. I often have ...
Alan P.'s user avatar
  • 3,153
1 vote
1 answer
1k views

I am facing an issue where every time i need to compare response body to some string i need to use response.body().toString() with await which just complicated the code unnecessary is there any other ...
Hindi Premee's user avatar
1 vote
1 answer
47 views

I'm new to promises and trying to get Promises.all to work in this situation. However, when I try to run the code by calling the processFiles function, it just immediately hits the console.log line ...
geoff swartz's user avatar
  • 6,057
1 vote
1 answer
173 views

I was reading some posts and got similar question in interview. Lets say the code snippet looks like this: const newPromise = new Promise((resolve, reject) => reject()); newPromise .then(() =>...
digital's user avatar
  • 11
0 votes
0 answers
50 views

I'm using the leaflet CDN script in a server-rendered app. The library's methods do not involve promises, so I often get weird UI glitches. For example, when I use setView() it returns immediately; ...
lonix's user avatar
  • 22.4k
0 votes
1 answer
457 views

I keep getting an error from the response of my promise, if I give it a parameter. I can't tell if I am suppose to pass in "columndefinitions" parameter to the apex method or not. I have ...
lache's user avatar
  • 850
0 votes
3 answers
173 views

I have tried to implement promise chaining in Javascript with 3 simple promises. First promise I am resolving and last 2 I am rejecting. Till 2nd rejection it is working fine. But after the catch ...
Soumya priyadarshi Das's user avatar
0 votes
1 answer
164 views

Hi in this code block my requirement is to execute the function test() such that it should stop executing ( it was going through an infinite loop and crashing the page) if it takes for than 1 min. I ...
Sourabh Raja's user avatar
1 vote
0 answers
285 views

i'm trying to understand the output of a test that i've been running because it seems to go against everything that i'm reading and hearing about how the node.js event loop works. supposedly all ...
prevail's user avatar
  • 43
-2 votes
2 answers
408 views

Consider the following assignments: const promise1 = (async () => { await someAsyncFunction(); })(); const promise2 = new Promise(async resolve => { await someAsyncFunction(); ...
OpenAI was the last straw's user avatar
0 votes
1 answer
374 views

How would I get the myPromise to be a normal promise instead of a ZoneAwarePromise? I've also unsuccessfully tried wrapping the resolve() in a NgZone.runOutsideAngular() and a setTimeout(). const ...
Jon's user avatar
  • 8,591
2 votes
1 answer
65 views

why does it print promise pending? I was expecting it might give promise<promise<1>> or promise<1> let k = new Promise((resolve, reject) => { let a = new Promise((res, rej) =...
Nikhil Harisinghani's user avatar
0 votes
0 answers
73 views

I'm writing a function that sends a POST request to my backend API and returns the response as data. I need to use a POST request because I need to send information to the backend. I'm using async/...
ceeb's user avatar
  • 1
0 votes
1 answer
96 views

I'm working on a time submission application for contractors that work on special projects. I have two select elements, projectSelect and payPeriodSelect. I use JavaScript promise chains to retrieve ...
benevolentBanana135's user avatar
0 votes
1 answer
42 views

I have an array of objects I am intreating that response I want on click of Read More button it will make an API call and display the result of the response and Read More button should not show for ...
Sandeep Mukherjee's user avatar

1
2 3 4 5
106