Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
-1 votes
2 answers
90 views

In section then3 I want to generate promises with further operations on their content inside 2 "thens". In case they were fetches, I want to limit their start to for example 3 at once every ...
Pirous's user avatar
  • 17
1 vote
1 answer
25 views

people. I have a Angular application which I am integrating with a node.js server. It works like this: A service is injected in the component The component calls the getAccountData() function from ...
Felipe Benévolo's user avatar
0 votes
0 answers
28 views

I'm trying to dynamically call external JS files. I'm using promise to wait for file to be loaded and then execute the code. How ever I don't want to run all the code inside positive promise. I'd like ...
Orbit's user avatar
  • 31
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
1 answer
75 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
2 answers
84 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
-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
49 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
0 votes
0 answers
30 views

I am quite new to Javascript, with my main programming experience in assembly language programming of micro-controllers. It has taken quite some time to adjust to it having so many 'system calls', (to ...
SaK's user avatar
  • 23
-2 votes
2 answers
401 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
2 votes
1 answer
78 views

Recently I've been given a following problem: console.log("start"); const promise1 = Promise.resolve().then(() => { console.log("promise1"); const timer2 = setTimeout(() => { ...
Roma Kim's user avatar
  • 371
1 vote
1 answer
65 views

This is the code: function SSD() { console.log('SSD') } async function createData() { let status = undefined try { const res = await fetch('https://api.github.com/users/Soumya-...
SOUMYA SANKAR DAS's user avatar
1 vote
0 answers
891 views

My case - "form data to be auto saved before navigating to new page". Firefox is cancelling form post with "NS_BINDING_ABORTED" and navigating to new page. Body - onbeforeunload is ...
Uma Sankar's user avatar
2 votes
1 answer
87 views

This is an interesting observation that I have made when experimenting with promises in JS. Consider this code: Promise.resolve(1).then(2).then(console.log); This prints out 1 as its output. ...
Napoleon Bonaparte's user avatar
2 votes
1 answer
188 views

I was recently watching a workshop video by Will Sentence on async javascript and I am having trouble understanding whether microtask queue always has priority over macrotask queue. function display(...
S Y's user avatar
  • 31
0 votes
0 answers
35 views

I received this as a coding challenge, but am unfamiliar with the concepts of promises, awaits, and awaits. // Asynchronous function that sleeps for a number of milliseconds async function sleep(...
Boo Shorty's user avatar
0 votes
1 answer
81 views

With Webflow native custom code editor, I added to my website an external script made by Finsweet inside the <head> tag, as they instruct to do. I want to make some changes in the page with my ...
Cormor's user avatar
  • 69
0 votes
1 answer
61 views

I need to combine simulated discrete time events that I faked with fake-timers with real http requests. Here is an example code const FakeTimers = require("@sinonjs/fake-timers"); const ...
CornFlow's user avatar
2 votes
3 answers
95 views

I'm just inherited a new codebase and this pattern in javascript seems to do nothing: /** * Update Data Model * @param {Object} model * @param {String} field * @param {Mixed} value */ function ...
George Beckert's user avatar
-1 votes
1 answer
197 views

All examples I see about Asynchronous JavaScript when they use callbacks, promises or async/await with a delay, to fake examples like waiting for something, make use of setTimeout() or setInterval(). ...
kavron's user avatar
  • 1
4 votes
2 answers
236 views

I recently encountered this question on Stack Overflow, asking about how the then method really works in JavaScript. The responder, Trincot, made the following comment: The host will check which job ...
Napoleon Bonaparte's user avatar
3 votes
3 answers
1k views

So, I was recently introduced to the concept of promises and I was told for chaining purpose, we use 'then', which is actually invoked when the attached promise object is fulfilled. And, to do some ...
curiousmind's user avatar
1 vote
1 answer
261 views

community! I've been recently discovering how JavaScript works and came across interesting moment with order of elements being executed in Job Queue and Task Queue. As we all know, Job Queue has ...
SKorchisnkiy's user avatar
0 votes
0 answers
55 views

I am a newbie in Node.JS. I am trying to fetch data from an api and filtering out data from a miscellaneous response. But my while loop is getting into infinite loop as the res array never gets ...
Sourabrata Bose's user avatar
0 votes
0 answers
122 views

I'm working on a Node.js project that involves performing multiple asynchronous tasks (API calls, database queries, etc.) concurrently. I want to ensure that my code is efficient and maintainable, ...
Ali Reza Riahi's user avatar
0 votes
1 answer
98 views

What I'm trying to do is: from my single page application, get data from an API using fetch. If the JWT is expired, ask the API for a new JWT and then renew the request for data. I tried to implement ...
thiebo's user avatar
  • 1,467
4 votes
4 answers
2k views

I have an Electron JS desktop application that is supposed to do some closing operations when it's closed or quit. However, the app is closing before my asynchronous operations are ended. How can I ...
Cyril Gupta's user avatar
  • 13.8k
0 votes
0 answers
83 views

In my API I want to execute long running function call in background and I dont want to use any task queue like RabbitMQ. I am trying to run long running function using events module of Node. But ...
Alok's user avatar
  • 10.9k
1 vote
1 answer
61 views

I have to write the body of a function getABC() which essentially has to take in responses from 3 different functions, getA()(synchronous),getB(callback)(callback driven),getC() (promise based). ...
Sounav Saha's user avatar
0 votes
1 answer
63 views

I wanted to convert callback hell to promises. function createOrder() { setTimeout(function() { console.log("order created"); setTimeout(function() { console.log("...
kdqdmmg0's user avatar
0 votes
1 answer
49 views

Why do I get a different output when using a do/while loop in the code below? function logNum() { let counter = 0; do { counter += 1; setTimeout(() => console.log(counter), counter * ...
noSelf_'s user avatar
  • 29
0 votes
2 answers
642 views

I'm building a small e-commerce store with an admin panel for myself. I use Firebase firestore as my backend to store all the user's data. I have a root 'users' collection with a document for every ...
Georgy Martynovich's user avatar
0 votes
1 answer
241 views

I'm having trouble to return a few keys from objects which are coming from promises callback function. The error I'm getting is on second country: Uncaught (in promise) TypeError: Cannot read ...
Roele's user avatar
  • 1
0 votes
0 answers
576 views

tl;dr I'm trying to return a data object in a synchronous function (which cannot be declared async due to the API constraints), but some of my data is in the form of Promise objects. I can delay the ...
ByThePowerOfScience's user avatar
2 votes
1 answer
2k views

Im trying to wrap my head around asynchronous javascript. So I wrote a function to test some things out. What I'm trying to do is write a scenario where I'm: Putting Popcorn in the microwave During ...
Bram's user avatar
  • 739
-1 votes
1 answer
86 views

I am new to JavaScript and, am not able to understand why the output of the following code:- let promise = new Promise((res, rej) => { setTimeout(() => { console.log("promise executed&...
Rosh's user avatar
  • 31
-1 votes
1 answer
55 views

This is the sample code: // Use zipURL to receive long and lat by using zipcode const userInfo = document.getElementById('userInfo'); const generate = document.getElementById('generate'); // Function ...
Rohan Asif's user avatar
0 votes
2 answers
2k views

fetch(url, { method: 'post', headers: { "Content-type": }, body: 'bar= foo& lorem=ipsum' }) Should it be? A) application/x-www-form-urlencoded; charset=UTF-8 B) text/html; ...
Jojo's user avatar
  • 81
-1 votes
2 answers
1k views

This is probably dead simple, but I can't quite figure it out. I simply want to read the contexts of a text file into a variable. What I have is: async function load(path) { try { const ...
Thomas Nicholson's user avatar
2 votes
1 answer
100 views

I am trying to retrieve data from a PSQL table. And this is my code for that: async function requestData() { var selectQuery = `SELECT "fName", "lName", "phoneNumber", ...
Dirghayu Joshi's user avatar
1 vote
0 answers
46 views

I've been reading a lot of tutorials as well as posts in StackOverflow regarding Event Loop in Javascript (Browser/NodeJS) and i'm currently a bit consfused on the terminology used when referring to ...
Apostolos Mavropoulos's user avatar
-1 votes
4 answers
1k views

I'm figuring out how to prevent any blocking code from blocking the main event loop. Suppose there's a function (let's assume it's going to block the event loop if implemented synchronously): function ...
Hemant Sharma's user avatar
1 vote
0 answers
647 views

Currently, I'm using AWS Secrets Manager to store my MongoDB (Atlas) ID and password. It is working fine for connecting to the DB; however, I'm facing challenges when I am trying to use the same ID ...
Koki's user avatar
  • 184
0 votes
0 answers
298 views

I have chained requests on GA API, meaning the second requests uses result from the first request. I wanted to use exponentialBackoff() function to retry if there is an error (status 429 for example). ...
iCanLevitate's user avatar
1 vote
0 answers
42 views

async function chicks(nest, year) { let list = ""; await Promise.all(network(nest).map(async name => { list += `${name}: ${ await anyStorage(nest, name, `chicks in ${year}`) ...
user avatar
0 votes
1 answer
625 views

I need to map over array of objects and change "photo property" in every object into it's base64 representation from the url im storing in databse. For this purpose I'm using imageToBase64 ...
Morghot2's user avatar
0 votes
1 answer
65 views

I have a question about asynchrony in JS. How it actually works. I'm not sure if I got it right, I hope you can help me figure it out. So, I have a code: console.log('start'); setTimeout(() => ...
Jhon's user avatar
  • 37
0 votes
1 answer
150 views

The following snippet of code freezes the CSS animation until it is done. I can't figure out why. I tried promises, async await, setTimeout, nothing changed. I want to have nice and simple loading ...
Max Lyoto's user avatar
0 votes
1 answer
189 views

I want to insert asynchronous data from Firestore into React elements. I have a couple of functions that handle the flow. getEvents() is an asynchronous function that returns an array of objects that ...
Hyziu's user avatar
  • 37
0 votes
1 answer
150 views

I want all these setState functions to run synchronously because as you can see, the functions running next to it depends on some of the value and it would produce the wrong result if the value is not ...
Areebuddin Phundreimayum's user avatar