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
0
votes
1 answer
Unable to store result value from a tesseract function to a global variable inside an asynchronous function
I'm using tesseract JS to convert an image into text format. The conversion is successful and I'm able to print it out in the console. But I am unable to get this text outside the scope of the function.
I have tried assigning the text to a global…

Sayyam Kapoor
- 145
- 2
- 13
0
votes
1 answer
Inserts executing after transaction.commit in Knex.js
I want to execute inserts in parallel in a transaction before finishing the transaction. I used Promise.all() and bluebird promises to cancel all the promises if one failed. The problem is that the promises seem to end before the inserts are…

LeoTheDev
- 60
- 1
- 7
0
votes
2 answers
Can I create my own "then()" function in Javascript and execute it?
I was going through a tutorial about Promises in Javascript. I saw usages of then() method in many places.
When I wrote the below code, I saw the "then()" function under __proto__ section of the console.
const myPromise = new…

user3742125
- 617
- 2
- 9
- 31
0
votes
0 answers
What Is the proper way to return a response from this promise?
I'm writing a voice-first application for the Amazon Alexa and Google Assistant platforms using the Jovo Node.js framework. I make nested http requests to an external API (the first call is to get a resource id needed as a parameter for the second…

Kevin Glick
- 157
- 2
- 12
0
votes
1 answer
Syntax Error: What's wrong with the below code
Help me resolve the below code showing syntax error. I know there is definitely some problem. How to write the below checkInventory order with the help of arrow functions.
const {checkInventory} = require('./library.js');
const order =…

Shivangi
- 41
- 6
0
votes
1 answer
0
votes
1 answer
setting variable in asynchronous javascript call
I have an object x of class C. The attribute x.myval should be set by calling x.load(), which in turn should get its data from an asynchronous ajax call.
class C {
constructor() {
this.myval = "hello";
}
load() {
return…

Markus
- 578
- 6
- 26
0
votes
4 answers
where callback is defined in this code
This is a code snippet for authentication using passports js, which is as follow,
// Middleware
passport.use('local-login', new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true
}, function(req,…

Umar
- 990
- 1
- 8
- 19
0
votes
1 answer
Using thunks: Why isn't my code printing sequentially?
I'm trying to understand thunks. I'm going through Kyle Simpson's Rethinking Async JS course on Lynda.
I have this code:
function makeThunk(fn) {
var args = [].slice.call(arguments, 1);
return function(cb) {
args.push(cb);
…

Asool
- 13,031
- 7
- 35
- 49
0
votes
2 answers
service call inside loop doesn't stops loop even if condition is false
I want to stop repeated call to getModelData if shouldPermit becomes true. But below code always prints why I got printed forEach newlySelectedUsers in console for each newlySelectedUsers.
var shouldPermit =…

sjain
- 23,126
- 28
- 107
- 185
0
votes
0 answers
How to clear chrome.storage on Chrome startup
I'm working on a chrome extension that uses an Event Page and I'm trying to completely clear it's local storage every time Chrome starts up.
This is what I have right now in eventPage.js:
chrome.runtime.onStartup.addListener(function() {
…

applemavs
- 503
- 3
- 9
- 22
0
votes
1 answer
Angular2- Asynchronous nested API calls
this.obsData
.concatMap((vhosts) => this.apiService.findVH(vhosts))
.subscribe((data) => {
this.data = data.docs[0]
this.data.Locations.forEach((loc, index) => {
if (loc.ip=== undefined) {
…

joshua1991
- 119
- 2
- 10
0
votes
0 answers
Javascript event loops in parallel
I am reading a book on Asynchronous programming in Javascript. So Async is implemented in serial but I read in this book that it is possible to have parallelism by having cooperating event loops in separate threads. I am just curious as to how and…

Andy
- 117
- 1
- 6
0
votes
0 answers
How to approach this scenario in async programming /node js
I am writing a service in nodejs. Please read below for the approach i am doing to solve this problem.
First I call a rest endpoint(say /offers) to fetch data . say it cloudSenseData
Final Response I need to massage/manipulate the data to give back…

Saikumar Kunchakuri
- 33
- 1
- 5
0
votes
1 answer
Unable to combine a normal form with Dropzone.js
In My Rails app I need the user to be able to post Facebook-style posts that would always contain text and optionally an image. I need this to happen without a page reload.
Since I'd like to use Dropzone.js to manage the asynchronous image uploads,…

alopez02
- 1,524
- 2
- 17
- 36