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
How to make setting state with useEffect() to run on page refresh?
My code is not long or complicated at all. It's simple. so please read!
(Im using react + next.js)
In the root file, app.js, I have useEffect to fetch photo data. This data array will be used in a page component so I pass it down from app.js via…

user18553387
- 57
- 6
0
votes
0 answers
Creating a soundtrack app in JavaScript to search and display tracks
I'm trying to build a small JavaScript program which allows the users to enter a search query, and then find the results of these query and display them through an asynchronous request. Below you can find what I tried so far, but it doesn't display…

Andrea Berger
- 107
- 6
0
votes
1 answer
React.js: Fetching Data from API with Bearer Token
I am building a React.js SPA, that receives data from an API with Bearer Token Authentication (so a fetch request for authentication has to be done first and the given token can be used temporarily to access the data until the auth session ends)
I…

David
- 57
- 1
- 6
0
votes
1 answer
Looping over JSON objects synchronously NodeJS
I'm requesting a JSON API then doing a for each loop over a JSON object and want a way to know once it's complete.
This is my current for each loop
Object.entries(jsonbody.data.users).forEach(([key, value]) => {
//code to run for each user
});
At…

Charlie Simon
- 133
- 12
0
votes
0 answers
Working with custom modules having asynchronous code node js
So, I have a file data.js(the custom module) with the following rough code(to not waste time understanding the whole code):
let data;
async function(){
data = await something; //the await returns an array, so data has an…

Haebel
- 1
- 1
0
votes
2 answers
Call a method in child component only after parent completes re-render
I have a graph with lower graphic quality displayed by a parent component . HeatMap has a child component, . MyButton is basically a button, which is dowloads the graph image. My requirement is: after button is clicked,…

Amiay Narayan
- 461
- 9
- 8
0
votes
2 answers
Typescript: how to call json() method on result of promise when result could be of type Response or void?
In my React Native app I make an API call and then try to apply the json() method to the result, like this:
await fetch(...)
.catch(e => {...})
.then(res => res.json().then(...)
Typescript throws a warning on json() saying Property 'json' does…

gkeenley
- 6,088
- 8
- 54
- 129
0
votes
2 answers
Passport, Bcryptjs, Async/Await: verify function passes any input in password as true
Everything in my passport-local strategy seems to be working, except the verifyCallback, where the truthiness evaluation of the validatesPassword function returns true regardless. The problem could stem from the fact that validatesPassword is an…

DeltaFlyer
- 461
- 2
- 8
- 17
0
votes
1 answer
I am getting an error in my map function returning React component
This is my code, in which I am running a map function on an array of objects, there are 2 condition check for each object, there is an async operation in the first condition and then the return statement. The error is this-
Uncaught Error: Objects…

Arun Pratap Singh
- 13
- 4
0
votes
2 answers
nodejs api not showing product for a particular product id
I'm trying to create a basic nodejs API(No Framework)
My Folder Structure is
controllers
productController.js
models
productModels.js
data
products.js
node_modules
package.json
package-lock.json
server.js
I'm trying to send product…

Nishant Kumar
- 691
- 1
- 11
- 31
0
votes
4 answers
Is there a way to write asynchronous code/function without any involvement of Web APIs?
I know it sound stupid because javascript is single threaded but can't help thinking about a function which takes unusual amount time with no involvement from web APIs like this
console.log("start")
function apple() {
let appleCount = 10;
…

AbHisheK ThaKur
- 63
- 5
0
votes
0 answers
Using AfterEach with different file module in NodeJS getting different values
I'm quite new in using Node JS, and I have been working on a test script that take screenshots whenever a test fails. And I'm trying to do this without the use of Jasmine reporter. I tried to use this approach instead Check if test failed in…

Nicolo_
- 11
- 5
0
votes
1 answer
Callback function returning promise instead of the value
I'm using fetch to grab data from a json file. In a .then(), I call a callback to do something with that data, and then eventually return the final value from the callback. The problem is that, when I return, it returns a promise instead of the…

ternt
- 21
- 1
- 3
0
votes
2 answers
Manage bootstrap modal with javascript
Good evening guys,
I program a symfony website by using webpack encore bundle to manage js & css.
I used to work with jquery which is quite simple, but would like to evolve to pure javascript.
I try to translate the following code in javascript…

juuk
- 11
- 5
0
votes
0 answers
Using YouTube API in a *blocking* way in JS
For a side project I'm working on, and for the sake of learning some more JS, I was playing with the YouTube API examples, trying to see how they work.
In Google's own documentation for getting playlists for a given YT channel we have the following…

Redoman
- 3,059
- 3
- 34
- 62