Questions tagged [asynchronous-javascript]

Asynchronous JavaScript is a technique to load JavaScript asynchronously using async and defer attributes or script tag injection. Not to be confused with AJAX.

91 questions
0
votes
0 answers

How to render an asynchronous result (array) in a component in react?

I have been doing js for about a month now, and I am writing this program where I am using clarifai API to see which celebrity a person on the photo resembles the most. I want to pass the output as props to Rank component to render it, but I get…
0
votes
1 answer

How can I read lines from .txt file, save in array, and print array asynchronously?

I have a .txt file that I want to save in a JS array and then console.log that array. I know from this answer how to read the file into an array, but the problem is when I try to console.log the array, it logs it as empty. Here's my code: const fs =…
0
votes
1 answer

NodeJS - rl.on() - read multiple numbers in multiple lines

EDIT : Thanks for the answers. I got the solution to achieve below with Promises. If this can be done without it in a simpler way please answer :) I need to take standard input like below 3 60 120 30 100 25 30 10 Variable form for above n W v1…
0
votes
2 answers

Angular 9 typescript how to make a function with a for loop to finish first before proceeding to the next function?

I'm currently learning more about the asynchronous aspect of angular and typescript so forgive me if my knowledge is lacking, I am currently facing a problem where I'm trying to implement promises to make a function which contains a for loop finish…
0
votes
1 answer

Can't use promises & async wait in AWS Lambda node.js working with docClient & Firehose

I am unable to understand how to reliably use async in node.js when working with firehose and dynamoDB functions. For example: async function dynamoDBToCSV(record) { ... try { const res = await…
monkey
  • 481
  • 4
  • 18
0
votes
1 answer

async function is not waiting at await

I need to scroll down before doing some action. my promise function is not waiting in await line. how can I solve this problem? let scrollingPromise = new Promise(async (resolve, reject) => { // I need this part to be done before resolving …
0
votes
1 answer

How to handle Asynchronous JavaScript code inside a while loop?

I was trying to fetch data from an API using $.getJSON(), but I ran into a problem. Maximum results per call which I can get is 50. However nextPageToken is provided by the api to get data from another page. In the while loop (below code) I want to…
0
votes
1 answer

html loads a new page before the jquery finishes the execution

I want to change the value of variable in jquery when the anchor html tag with link is clicked , this tag also loads new page but when I click on that anchor tag new page is loaded but the variable value is not changed. I looked on the internet and…
Tushar Sureka
  • 39
  • 1
  • 7
0
votes
0 answers

How to handle callbacks?

I have a function which is -: function generateAndEmitSessionizedEvents(workflowIdVsClientId, workflowIdVsEvents, clientVsIdVsDoc, esWriteFailedWorkflowIds) { return _generateSessionizedEvents(workflowIdVsClientId, workflowIdVsEvents,…
0
votes
0 answers

Stepping into an async function

I'm trying to fetch data from an API, and encountered an issue. The function fetchCountryData doesn't help debug the issue because any breakpoints inside it are ignored. How do I step into an async function? const [countryData, setCountryData] =…
0
votes
2 answers

How to wait for the whole recursion to finish before moving on in Javascript?

I am new to reactJS and am trying to build a sorting visualizer. The problem I am facing is while implementing the quickSort() routine. My quickSort() routine is as follows: async quickSort(array, p, r) { if(p
0
votes
0 answers

How to write asynchronous function when I call another function in Node.js

I am calling multiple functions after receiving response.The other functions are executed before earlier functions.So I've set timer to stop the execution.But I would like to refactor it with asynchronous functions. const testStaticData = [Ptesting,…
BTVS
  • 21
  • 4
0
votes
1 answer

Self monitoring of mongodb with nodejs

I want to get serverstatus data from mongodb on nodejs for all my users(of their respective databases). I have to do this repeatedly unless user makes x field false. N when he turns it true again I will have to start fetching data again. I thought…
0
votes
0 answers

returned object by callback has no method in itself to run

i wrote a code which send a get request by jquery-ajax,also i use a call back to return the result of this request.But the returned value has no applicable method in itself(when i press alt+space i have nothing in that menu).the question is why? any…
0
votes
0 answers

async methods for running parallel jobs

I am working in a program that has below steps: fetch user data from Database(it has more than 2000 users get list of roles for all users( each user might have roles) send mail to those users which has more roles Running them synchronously will…