Asynchronous JavaScript is a technique to load JavaScript asynchronously using async and defer attributes or script tag injection. Not to be confused with AJAX.
Questions tagged [asynchronous-javascript]
164 questions
1
vote
1 answer
How implement back pressure manually
i have child process in that i am piping stream to parent.
in child.js
let stream = readdirp(pathname);
stream.pipe.pipe(process.stdout);
in parent.js
let file = child => {
let estream = es.map((data, next) => {
…

Ram
- 432
- 5
- 23
1
vote
0 answers
Handle NDJSON Stream Promises in Stache Can.js
I have this streaming API endpoint:
https://step3-ndjson-stream-api-demo.glitch.me/
I try to render with can.js NDJSON stream and following the example got some success output to console.log but only the first object.
Here's my app.js…

Ardhi
- 2,855
- 1
- 22
- 31
1
vote
2 answers
API Call in Rocket.Chat Integration
I am trying to further extend the telegram-rocket.chat bridge and need to call some apis for that. For this, rocket.chat exposes a Meteor.js wrapper called HTTP.
This code snippet is an outgoing-hook that processes a message sent by a user, lets me…

Michael Kargl
- 662
- 10
- 21
1
vote
1 answer
How to test a asynchronous server code using mocha chai?
In my mocha-test suite, I want to test a functionality which makes a asynchronous call behind the scene. How can I wait until the asynchronous call has finished ?
For example, I make two back to back post calls. The first post call also makes an…

A.G.Progm.Enthusiast
- 846
- 14
- 29
0
votes
0 answers
Issue with the return statement in the Transaction in express js
I'm running a transaction in express js. Following is the code:
app.post('/register', (req, res) => {
const { name, email, password } = req.body;
const hash = bcrypt.hashSync(password);
db.transaction(trx => {
trx.insert({
…

Tilak Shukla
- 1
- 1
0
votes
0 answers
Looping while receiving data from async request module
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 populated due asynchronous behavior of request.
let…

Sourabrata Bose
- 1
- 2
0
votes
0 answers
How to efficiently manage multiple asynchronous tasks with error handling in Node.js?
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, while also handling errors properly.
Here's a…

Ali Reza Riahi
- 1
- 4
- 14
0
votes
1 answer
order of execution of several fetch calls
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 this with 3 functions: getData calls fetchData.…

thiebo
- 1,339
- 1
- 17
- 37
0
votes
0 answers
How do I make rendered html page using Asynchronous communication (Fetch API)?
In My Team project, we made rest api using Java Spring boot.
And we made frontend server using node.js and express modules.
but when launched nodemon app.js, my page didn't rendered to html page.
I attached json data using fetch, javascript code,…

Casey
- 21
- 3
0
votes
0 answers
UseState is not updating value in first attempt?
I am running the following snippet. On first time I Click on the onClick button it should show "Hi, I am ammad jahangir" it shows ammad. I want to know the reason.
import logo from './logo.svg';
import './App.css';
import { useState } from…

Ammad Jahangir
- 1
- 1
0
votes
0 answers
How to make event listener run asynchronously in events module of Node without using setImmediate() or process.nextTick()?
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 EventEmitter calls all listeners synchronously in the…

Alok
- 7,734
- 8
- 55
- 100
0
votes
1 answer
Asynchronous Javascript Promises code stop at "order created", how to fix the issue?
I wanted to convert callback hell to promises.
function createOrder() {
setTimeout(function() {
console.log("order created");
setTimeout(function() {
console.log("order received");
setTimeout(function() {
…

kdqdmmg0
- 19
- 6
0
votes
1 answer
Inconsistent output using do/while and for loop in asynchronous JavaScript using let to declare the variables
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 * 1000);
} while(counter <= 10);
}
logNum();
The…

noSelf_
- 29
- 5
0
votes
2 answers
Vuex action does not work properly in a vue mounted hook
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 single registered user and everything else each…

Georgy Martynovich
- 347
- 3
- 9
0
votes
1 answer
Jonas Schmedtmann's Asynchronous coding - Chaining Promises - restcountries issue
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 properties of undefined (reading 'png')
'use…

Roele
- 1
- 1