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
1
vote
1 answer

Call Asynchronous functions with Chai request

How to assert the values from asynchronous function while using Chai as assertion library const testData = ['PTesting', 'P2', 'P3'] describe("End to end testing.", function () { before(function () { logger.info('End to end test cases…
BTVS
  • 21
  • 4
1
vote
2 answers

React - how to set state with the data from a resolved promise

I'm struggling to get my data from a fetch request into the state of my container My fetch request is stored in api.js and looks like this - it retrieves the key from a constant which is fine:- import { openWeatherKey } from './constants'; const…
blake
  • 180
  • 9
1
vote
0 answers

Redux saga: how to put a `yield put()` inside an event listener?

I'm using Redux saga and OneSignal in my React Native app. In my saga I have the following generator function: function* getOneSignalIDs() { try { OneSignal.init(appID) OneSignal.addEventListener('ids', (device) => { …
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) => { …
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…
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…
0
votes
2 answers

Why these codes about the timer(setTimeout()), the then() method of Promises running like this?

const wait = function () { return new Promise(function (resolve, reject) { resolve() setTimeout(console.log('a'), 5000) }) } wait().then(() => console.log('b')) Explain the code: As you can see above, i created a wait() function that…
0
votes
1 answer

What do the gaps mean in the diagram given in page 181, chapter 11: Asynchronous programming in the book Eloquent Javascript?

I was reading "Eloquent Javascript", chapter 11 on asynchronous programming and there is a diagram given on page 181 contrasting the differences in single threaded, multithreaded and asynchronous techniques in the case of sending two network…
0
votes
0 answers

Why is my JavaScript asynchronous function not running till everything else finishes?

I am having a bit of a hard time understanding how javascript asynchronous functions work. In my actual use case, the function in question is a 3rd part API call but a simple setTimeout function is a simpler way to reproduce my problem. I expect the…
0
votes
2 answers

Error Handling in Javascript asynchronous functions. Conceptual query. Possibility of Having an umbrella try-catch in node.js for multiple layers

Queries: Why does the try block not catch the error in the asynchronous method in Javascript? Could it be understood in terms of execution context? Is there a way in which we could wrap all error handling in the entry file or at a higher…
0
votes
1 answer

Javascript asynchronous web crawler

I have an async function that reads a list of websites from a csv file. async function readCSV(){ const fileStream = fs.createReadStream('./topm.csv'); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity …
0
votes
2 answers

Async and Await not working with Axios React

I am trying to test my react project locally with my computer and with my phone. I am using JavaScript not TypeScript. When I run the project on my computer everything works fine, but when I try to load it on my phone, I get an error: Unhandled…
0
votes
1 answer

Javascript create async function without breaking the application

I have a project where I have a horizontal bar that has an overflow. At the beginning and end there are buttons that move the overflow position. At this point the user has to click on the buttons in order to move the overflow. I wan't to create…
Stephen
  • 338
  • 5
  • 18
0
votes
0 answers

React app keeps sending multiple request on its own

I'm new to react and I'm trying to build a Weather App for my project. It keeps sending the request to the API I'm using which is OpenWeatherMap API. I'm using Axios to send the request. Here's what my code looks like: import React, {useEffect,…
0
votes
1 answer

Use DirectionServices asynchronously

I am a Java developer student and I have a problem understanding how to properly write asynchronous functions in Javascript. I read a lot of tutorials but I don't find a good way to implement proper asynchronous methods all the time. I am making an…