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

React Native Geolocation: Why is this async function returning undefined?

I have the following function: func = async () => { let location = await getLocation(); console.log(location) } it calls this function getLocation = async () => { Geolocation.getCurrentPosition( (position) => { …
0
votes
1 answer

Are there only some spefiic callbacks that are processed inside the event loopin Nodejs after the call stack is empty?

1.const geoCode = (address, callback)=> { setTimeout(()=> { const data ={ longitude: 0, latitude: 0 } callback(data) }) } geoCode('John', (data)=>{ console.log(data) }) 2. const forecast =(longitude, latitude, callback) =>{ …
0
votes
1 answer

How to use await/async properly in Nodejs Azure Function App

I am trying to write a code to connect with snowflake inside the azure function app using nodejs stack. Here is the code I have writtern. async function af2snf() { console.log("starting connection"); var snowflake = require('snowflake-sdk'); //…
0
votes
0 answers

Asynchronous Programming in JavaScript - Callback Steps Execution

I would like to ask you to explain one thing to me. I just started learning a concept of "Asynchronous Programming" in JavaScript but for some reason I struggle to "visualize" this code in my head. function add(a, b, callback) { callback(a +…
0
votes
1 answer

implement a promise to return the slower of two promises

I'm new to asynchronous programming and I'm only getting familiar with the idea of promises as a replacement for callbacks. I'm trying to implement a function ( promise) to take in two other promises, and that will return the value of the one that…
Ed_
  • 347
  • 1
  • 8
0
votes
0 answers

Will a callback not work in this situation or should I use an async/await? Or am I not able to return a buffer?

I asked an earlier question last week concerning something kinda similar to this and it was immediately closed as I was referenced to a question about Asynchronous JavaScript. I tried to follow what seemed like the favorable opinion to use an…
0
votes
1 answer

How to make function work after another (which contains ajax request)

I have 2 finctions: first load svg on page, second change color of certain in some svg. This functions looks like: get_svg_part(category,position,part_name); -- contains ajax svg_part_color(category,position,color,parameter); -- need execute…
Osigot
  • 17
  • 6
0
votes
1 answer

How to use functions of java script library which is called asynchronously by my web page?

1. My local js file sdk.js is (function(sdkUrl,b,flag) { if (window[b]) return; if (!window.JSON) return; let url = sdkUrl; let h = /Chrome\/(\d+)/.exec(navigator.userAgent); h…
0
votes
1 answer

How to call one HTTP Call inside another HTTP Call in a for loop in AngularJS?

I am working on an AngularJS Application. I have the following array: $scope.fruits = [ {url1: 'appleColor', url2: 'appleDetail'}, {url1: 'orangeColor', url2: 'orangeDetail'}, {url1: 'grapesColor', url2: 'grapesDetail'}, ]; Now,…
0
votes
1 answer

if an error is thrown at some point in a promise chain, is it automatically propagated all the way down the chain?

Say you have a promise chain like this: asyncFunction() .then((value) => { resolve(value) }) .then((value) => { resolve(value) }) .then((value) => { resolve(value) }) .catch((error) => { reject(error) }) If an error is thrown during…
0
votes
1 answer

JS Promises: Why is it that you can't set code to execute after the callback of setTimeout?

I'm reading this article on promise chaining in Javascript, and am confused about the section where it says how can we do something after the avatar has finished showing and gets removed? For instance, we’d like to show a form for editing that user…
0
votes
1 answer

Multiple asynchronous call in cascade in recursive function JS

I already know this question has been asked many times but I can't figure out how to oganize my code. I'm coming from C/C++ language and still have the way of think, and what I'm writting in JS looks 'meaningless'. I'm using a recursive function in…
0
votes
0 answers

Sync request after many request

I've a Upload file functionality, I send the file in parts so, many request was made, when I upload the file I use async : 'true' in $.ajax({});, then when I click in other tab, request to get list of book's names for example ... and request is…
0
votes
2 answers

NodeJS function that returns resolved promise value instead of the promise?

I have a function that uses the request-promise module to scrape and parse HTML from a website. I want the function to just return some JSON data when it's done, and not a promise. Here's the slimmed down version of the code I have so far: const rp…
0
votes
4 answers

How to correctly handle a series of async calls inside a parent async call

I have a use case where I want to make an async call (consider it similar to ajax) and then in success block of that call I want to make a series of async calls in a loop using the id which is generated by parent call. My requirements are : Where…