Most voted "async-await" questions
45 questions
Sort by count of
-
29
votes7
answers9251
viewsIn C#, what is the await keyword for?
I was studying this documentation about Asp.net Identity, and in the examples in C# has a keyword that I don’t know, which is the await, example : [HttpPost] [AllowAnonymous]…
-
13
votes1
answer545
viewsHow does ES7 async/await work?
ES7 allows you to use a new syntax to work with Promises known as async/await functions. How I can use these functions and how they are compared to functions that use Promises to process sequential…
javascript asynchronous ecmascript-6 promises async-awaitasked 8 years, 3 months ago Gabriel Gartz 5,624 -
9
votes2
answers1801
viewsAsync/Await with threads (C# 7.2)
I have this code and as you can see I created two examples, Parallel and Notparallel. I expected both to return me 3000ms, because both should run async (2000 and 3000) and the total time would be…
-
5
votes1
answer247
viewsAsync/await generates a new thread?
When reading about async/await methods, it is said that using these keywords alone will not cause your method to run in a new thread. However, I get the output below by running my code. A thread was…
-
4
votes1
answer176
viewsHow to use . reduce with async/await?
In synchronous code I can have a .reduce to make a sum calculation (as in this simple example of a shopping list): const tipos = ['leite', 'manteiga', 'pão']; const precos = [23, 21, 32]; const…
-
4
votes1
answer93
viewsFunctions with async / await running out of order
Can anyone explain to me if this is the expected behavior, or if I made a mistake in the code below? The expected behavior (in my understanding) would be to log 1,2,3 in sequence. let funcao1 =…
-
4
votes2
answers110
viewsIs it possible to use Async Generators with the ES5 syntax?
For example, the code below that creates a async Generator: async function* iterate() { yield 1; yield 2; yield 3; return null; } Could be used with the syntax for await...of: for await (const…
-
3
votes2
answers784
viewsProblem accessing Json API with React
I am trying to access the following variable in the Json of an API: page[0].infoBloco[0].tabela[0].dados[0].fonte.nome I’m getting the bug: TypeError: this.state.page[0] is undefined[Learn More]…
-
3
votes1
answer210
viewsReturn a function to be executed - Typescript
I’m in a situation where I would like to generate an engine that runs an async function and that runs a successful callback on Ry and a catch error, and the responsibility of these callbacks is to…
-
3
votes2
answers291
viewsPerform another action during a await Task.Delay
I’m making an application where comes a certain part of the code I need to put a: await Task.Delay(tempo); But at the same time I have to wait around this time I need execute an action every 10…
-
3
votes1
answer82
viewsWhat are the differences in backend and frontend?
When we use async and await in the backend and frontend ? Is it better? It’s worse? Other related questions: An API, for example in C#, if all methods are async and await, I can say it’s better than…
asynchronous language-independent async-awaitasked 5 years, 1 month ago Samuel Renan Gonçalves Vaz 720 -
3
votes1
answer109
viewsHow to use await instead of . then() in Javascript?
I have this asynchronous code: const delay = () => new Promise(resolve => setTimeout(resolve, 1000)); async function umPorSegundo(){ console.log(await delay(), '1s') console.log(await delay(),…
-
2
votes1
answer157
viewsWhy is it not possible to capture exceptions triggered by async void?
Why it is not possible to capture exceptions triggered by non-recurring asynchronous methods Task? public async void calcularPrecos() { var tabelaPreco = await getTabelaPreco(); /* Blá, blá, blá...…
-
2
votes1
answer10860
viewsHow to use async / await in get request using Vue+Axios?
I have the following code and would like to know how I can implement a Try / catch with async / await running the same function: import Vue from 'vue' import axios from 'axios' new Vue({ el: '#app',…
-
2
votes1
answer41
viewsHow to wait for the previous function to create the component on the screen and then take the data from that component (javascript)
Good morning, I’m having trouble getting the values of a select Box from my screen, the situation is as follows, I create the page normally with the default values in select Box ex: Carrying...…
-
2
votes0
answers49
viewsWhat is the point of using await in asynchronous methods?
Studying on asynchronous/synchronous operations one point was not clear, which would be the use of the await in methods async as in this example found on MS’s own website. If the method…
-
2
votes1
answer41
viewsPromise solved or rejected multiple times by "blocking" execution of the rest of the code
My goal is to get the user’s email and then send it to the database. For this, I put a "change" event in the input that captures the email. My idea is that every time the input goes out of focus,…
-
1
votes1
answer438
viewsError passing parameter through Getasync method
How I pass the object login as a parameter for the method GetAsync ? I’m trying to do it this way, but I didn’t get the error message: private async Task<JsonResult> obterLogin(Login login) {…
-
1
votes1
answer46
viewsUpdate main form after closing the load form
What I’m trying to do is, I need to open another form in another thread where there is a Progress bar that is indeterminated, and in the main ui I need to update the datagrid with the data from the…
-
1
votes2
answers96
views[[Promissevalue]] React
I’m doing a get an api on Nodejs, only the result is coming back within a [[Promisevalue]], how do I access it directly? With async and await it works, but when for it to authenticate on the route…
-
1
votes1
answer149
viewsNode js loop Time
I am performing these functions below in a for. The functionality is almost doing what I wish, but I wonder if it would be like after running const q = await clientOut.write(p[i]), wait at least 3…
-
1
votes1
answer1228
viewsHow do I put Axios.get back into a variable?
I made an access to the database and with Axios.get I got the return but I need to store this return in a variable so I can use it further, but when I tried to get it as a result: Promise { :…
-
1
votes1
answer82
views.then() in Async/Await
How I would transform the following function using async/await? const delay = () => new Promise(resolve => setTimetout(resolve, 1000); function umPorSegundo() { delay().then(() => {…
-
1
votes0
answers14
viewsCommunication with Arduino via await async . NET
Good afternoon! I’m studying the best way to communicate my web project with an Arduino board. So far I’ve managed SEND an asynchronous form of a command, according to the code below: //metodo para…
-
1
votes1
answer49
viewsI am having trouble synchronizing the execution of this program -- JS, Promise, async and await
Guys, I’m having a question, I’d like to read an Excel spreadsheet, store your content in a variable and then display it on the screen. However the method that reads the file -- parseExcel -- occurs…
-
1
votes1
answer38
viewsHow to use Async/Await Asp . Net Core correctly
I am using asynchronous requests in various parts of the project, but a doubt has arisen because I know that for a method to be asynchronous it is necessary the same being async and have a await.…
-
0
votes1
answer335
viewsHow to use async and await in Nodejs
I am trying to learn how to use async await but, I am missing something and I need help. My method works as expected with Promise see: import express from 'express'; import conn from…
-
0
votes1
answer72
viewsHow to create a method that does not wait to finish to return OK
I need to create a method that returns "OK" immediately, without waiting for a method called by it to end. how to do this? [WebMethod] public string ImportaDadosPosLeilaoValores(string fileName) {…
-
0
votes1
answer95
viewsPopular object with async/await nested
Personal talk, I am consuming the Trello API to retrieve items from card-specific checklists of a frame. So I am making the following path. Retrieving information from the table Retrieve information…
-
0
votes2
answers154
viewsPromise async/await not resolved
I am doing . map() in an array, to do a Mongoose/Mongodb query with each element of this array and returns another array with the results. However, after this process, I try to access the new array…
-
0
votes1
answer240
viewsAdd attribute to a json
How do I add an extra attribute to all elements of a JSON that I receive, to then display on the screen? When I try to make one map in the JSON that I receive from the request and add the item in…
-
0
votes1
answer46
viewsManipulating Async/Await function return with JSON.parse - REACTJS
I have the code below that is returning an error where I am not understanding how to solve. The log console of "Ret.value" returns {"id":1,"name":"Max"} string correctly, but in JSON.parse. Argument…
-
0
votes1
answer115
viewsAsync Await in Javascript blocking synchronous code execution
If I understand correctly, a function declared with the keyword async must return a promise. In the case of the function async3() we have 1 billion iterations, which makes the return value take a…
-
0
votes1
answer42
viewsIs it possible to use ASYNC AWAIT when receiving a PROMISE return?
I would like to know if it is possible to receive the return of a Promise using async await? I created a file where I read a file and return the string of that file, to receive this variable, in my…
-
0
votes1
answer68
viewsLoop of promises does not return JSON in Node.js
I have an array with the Events to be searched, to check if there is another one on the same day and time. The code below returns me the existing events without problem, but only on the console.log.…
javascript node.js promises async-awaitasked 3 years, 10 months ago Thiago Augusto Monteiro Pontes 3 -
0
votes1
answer16
viewsgraphql and Apollo server error in start Apollo server
I have a problem with graphql and Apollo server and do not know why this error persists and do not know how to solve. Even putting 'await server.start()' still giving error SyntaxError: await is…
-
-1
votes1
answer112
viewsNode.js - problems with async/await in a setInterval()
I am developing a bot to monitor an application. The function areaDocenteMonitor.start() makes only one request and returns the status. If the status is different from 200 an email is triggered with…
-
-1
votes1
answer220
viewsHow to save asynchronous function return solved
To save the result of a solved asynchronous function to a variable to use the result later along the code ? Example: How do I save function result joinStrings in a variable outside the async…
-
-1
votes1
answer26
viewsI am unable to iterate the array
I would like to popular this array with the Category object I get when I query findById. But the variable loggedUserCategories appears as an empty array in Sponse , however, I can visualize the…
-
-1
votes1
answer39
viewsCatch Return of Async Function in External File
I have 2 files in both async use / await and return a promisse. So far so good. But my question is what to call them in Controller. I’m managing to return all recipes, however, I’m not able to add…
-
-1
votes1
answer49
viewsfunction only returns predises
I’m studying on JS with Node and Express. I am developing an application that will consult emergency relief data through the GOV API. I have a function that returns the JSON data of a given CPF, it…
-
-1
votes1
answer9
viewsHow to make Nextjs not return props before getStaticProps has completed all requests (Promises)?
Within the function getStaticProps I take some data from the database and perform in them some treatments to suit the way I will use them. Everything happens exactly as it should, except that…
-
-2
votes0
answers21
viewsWhy async does not work on google Chrome mobile 92.0.4515
I am learning to work with async and I am testing the compatibility with old iphones, I am using the google Chrome of iphone 5s that is in version 92.0.4515 however I realized that async does not…
-
-2
votes1
answer34
viewsJavascript with async-await
I am using async-await in the SQL query function in the Model and I use the MVC standard. The problem is that when executing the function (select SQL) in the model it is executed but the return is:…
-
-3
votes2
answers84
viewsStrange return even with Async/Await
I have the following functions in common.js import AsyncStorage from '@react-native-async-storage/async-storage' const getData = async () => { try { const jsonValue = await…