Most voted "promises" questions
An object preserves the promise that the function it generated will sometime in the future end and return you a response. It can be a positive or negative response. The Promise can be passed to other functions or returned.
Learn more…133 questions
Sort by count of
-
2
votes1
answer74
viewsType annotation in asynchronous functions in Typescript
I am new to Typescript and I have the following question. It is necessary to be explicit about the type of return of a request fetch? const getPeoples: () => { userId: number, id: number, title:…
-
2
votes1
answer66
viewsHow to put an input value to be analyzed in a Promise?
"Create a function that receives a user’s age and returns a Promise that after 2 seconds will return if user is older than 18 years or not" When I open the page after 2 seconds the result loads even…
-
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
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,…
-
2
votes1
answer72
viewsHow to convert a Promise-based function to callback in Javascript?
We can convert asynchronous functions that work with callback to work with Promises, as shown in the examples below: callback: const timeInMs = 1_000; function asyncCallback(timeMs, callback) {…
-
1
votes2
answers3408
viewsCheck if URL exists
I would like to know how to valid (know if there are) URL’s of social networks, I am using the AngularJS, AJAX and http requests but I can get the status of a URL I created in a mock, but I can’t…
-
1
votes1
answer375
viewsHow to finish a loading screen after running Presets in Angular?
Good morning. I have a question, I have a controller that searches some data of a webservice Rest, and persists them in the device database (Ionic), to perform the search of the data, I am using…
-
1
votes1
answer56
viewsUsing Q Promise to receive different Apis values
I need to get the values of some Apis. For example: calls to api1() and api2() return deferred.promise; I can do: api1().then( function(res1){ api2().then( function(res2){ console.log(res1, res2);…
-
1
votes1
answer156
viewsWhat are the differences between Thread and Promise
I am more of the desktop world, but I’m wanting to know more about WEB. And I wonder if there is a difference between javascript and C thread#.
-
1
votes1
answer250
viewsHow to get a return from a foreground nodejs
I can’t figure out how to get back a Password in Javascript. In the example below, how to get the return of const info? const GoogleSpreadSheet = require('google-spreadsheet'); const credentials =…
-
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
votes0
answers212
viewsReturn a variable (Singleton) using Node that depends on Promise
Good afternoon, you guys, It has to create a variable in Nodejs/JS where I would return a value only to be used several times throughout the program? Exemplifying my problem: I have to log on to a…
-
1
votes1
answer62
viewsEvaluating the $http response from Factory to the controller in Angularjs
I created a Factory to carry out the operations CRUD in a REST API using the $http service to make a user control. Factory //Listar..Recuperar ..Inserir ...Editar..{...} usuarioService.Excluir =…
-
1
votes0
answers43
viewsWhat is a Promise?
Why does it exist? How does it work and how should it be used in the simplest way? Any specific care? When is abuse to adopt this mechanism? Exists only in Javascript?
-
1
votes2
answers22
viewsHow to update a service collection by calling index a second service?
In the call of a service within my controller I carry little data, and as soon as this data is loaded, on the screen, behind should come the complete data for a particular filtered item, the…
-
1
votes1
answer296
viewsCalling class method within a prefix returns: Uncaught (in Promise) Typeerror: _this3.updateShelvesState is not a Function
Good Afternoon! I created a method called updateShelvesState which is called before the component is rendered, and onChange of another component called Book. This method takes an array and creates a…
-
1
votes1
answer333
viewsUpdate sweetalert 1.x to sweetalert 2 + javascript Promises
When updating the library Sweetalert it stopped working, while debugging the error I saw that it had many modifications that made the version 1.x incompatible with the new version, so I would like…
-
1
votes2
answers236
viewsPromises in Nodejs
I’m learning Node and picking up some of the asynchronous programming. To learn, I took the following example console.log("1"); setTimeout(function(){console.log("2");},3000); console.log("3");…
-
1
votes1
answer35
viewsIonic loop reading sensor and sending to api
Hello, I need to take consecutive readings of some sensors in Ionic 3.x but I can’t let it completely block the application. tried to do so: async disparaLeituras(path_id) { while (true) {…
-
1
votes1
answer168
viewsReturn in Promise
Hello I have a function that brings the ip in httpbin, however it is a file and I can’t put the result in a Return, only when it runs with console.log another direct mode: Funciana like this...…
-
1
votes3
answers308
viewsDoubt when exporting Promise
I have an async Function that does a get for an api and returns a random word: word js. require('dotenv').config(); const config = require('./config.js') const axios = require('axios'); const…
-
1
votes2
answers575
viewsHelp with Promisse {<Pending>}
Talk personal, all right? I’m doing a role that will be responsible for validating the ZIP code informed by the user. Basically in the call of an API the user will send the ZIP code on body and I…
-
1
votes1
answer39
viewsUse value that is filled after a Promise
Guys, I’m developing an application that, according to the code below, searches the data in an API and with the result of this, makes other calls and makes a push in a variable, how can I access…
-
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
answer266
viewsFloating promise check in Typescript Eslint (no floating Promises)
I have the following method: async sync({model, event, data}: {model: string, event: string, data: Category}) { if (model === 'category') { switch (event) { case 'created': await…
-
1
votes1
answer127
viewsArray map and asynchronous functions
I’m using the function getStaticProps from Next.js and Axios to pick up news from Hacker News. My goal is to access the API that returns the main stories of the day (which returns a unique id of…
-
1
votes0
answers42
viewsProgram does not return to the loop after executing function
I have a robot that accesses an online system and downloads the files. It works with a delay between one download and another, but is taking time. On this system, I can only close the open tab after…
-
1
votes1
answer111
viewsHow to return the value of a function that uses Javascript promises?
I have a function that should check if a user is enrolled in Stripe. For this is made a request to a third server that returns an array of users. When I make the request, a promise is returned:…
-
1
votes0
answers25
viewsConcurrent React JS requests with queued AXIOS, without using Promise.all or Promise.allSettled
I have the following situation: a form with a single input and a list with results that will be displayed on screen. The idea is for the user to enter a code in the input, and when changing the…
-
0
votes1
answer340
viewsReturn of javascript asynchronous methods
I would like to save the return of an asynchronous function. The function is as follows: cb.tabela(serie).then(function(tabela) { console.log(tabela); }, function(err){ console.log(err); }); I wish…
-
0
votes0
answers314
viewsDifference between Try-catch / then-catch
I just started the Promises study and came across the second dilemma: What’s the difference between using Ry and catch to handle errors and then and catch? What’s the best case for each of them?…
-
0
votes2
answers66
viewsPromise executed out of order, how to resolve?
I’m using the setTimeout function in the form of Promise, following the example of the Mozilla documentation. It turns out that the callback function is running before the end of the counter,…
-
0
votes1
answer377
viewsAccess variable from within the scope of Promise
I have a Factory that must access two other services. Being the following structure: angular.module('my.module') .factory('ServiceMain', ServiceMain); ServiceMain.$inject = ['ServicePrimary',…
-
0
votes1
answer62
viewsHow to export the contents of a promisse that is in a module to another module?
I have the following module getToken.js: var rp = require('request-promise'); const options = { url: 'https://meuservidor:8080/nifi-api/access/token', method: 'POST', gzip: true, rejectUnauthorized:…
-
0
votes1
answer672
viewsTraffic lights in Javascript
How can I create traffic lights in Javascript? I have an asynchronous script that runs n times, I wish that when the n tasks had another task been executed. I used normal access to a variable but…
-
0
votes2
answers239
viewsPromise on JS How to Abort/Cancel an Ongoing
I have an async function saved within a const, I would like to finish it after a while example: const p = async () => { await Model.create(); return; } const promise = p(); console.log(promise);…
-
0
votes1
answer28
viewsHow to send this "dt" variable to Promise.done?
I have the following javascript line: ... var refundVal = $( ".refundVal" ).val(); var dt={ orderId:orderId, refundVal:refundVal, process:btnProcess }; window.srObjc.confirm("message $"+refundVal+"…
-
0
votes1
answer52
viewsObject key is not recognized after using fetch
The console indicates a wrong saying Uncaught Typeerror: Cannot read Property 'name' of Undefined. within the scope of the function in which API access can access name and other keys. the code:…
-
0
votes0
answers47
viewsIs using Promise wrong (deprecated) nowadays?
Well, I work with angular nowadays and I always wonder if it is wrong to use Promises or not, example. I have a code that needs to be async. First function must validate the access permission, after…
-
0
votes1
answer30
viewsCheck if Node created with insertAdjacentHTML in a loop is "visible"
I’m looking for fragments of HTML with fetch() and adding to the DOM with the function insertAdjacentHTML() in a loop for()... the function that performs this task is in a Promise() and its return…
-
0
votes0
answers62
viewsI cannot run a query inside a socket event using Node.js (socket.io), why?
Follow what I did initially: var http = require('http'), express = require('express'), mysql = require('promise-mysql'), mysql2 = require('mysql'), parser = require('body-parser'), path =…
-
0
votes1
answer52
viewsPromise Javascript
I have a scenario where I make several Ajax calls to a Webapi and with the return I load controls from an application. I would like to create a unique method to call the API, which would receive a…
-
0
votes0
answers70
viewsNode return page
I have the following code pad server.get('/energy', (req, res, next) => { { const getScript = (url) => { return new Promise((resolve, reject) => { const http = require('http'), https =…
-
0
votes1
answer614
viewsMake Angular4 wait for callback to API without timeout
People see if someone can help me. I need to make a call on the API, but it’s a lot of data, and I want Angular to wait for that termination, At that moment I put a file but it does not wait and as…
-
0
votes2
answers289
viewsPromise/Observable Chaining in IONIC/Angular
Personal I am new in IONIC/Angular and I do not understand yet very well Promise/Observable and would like a help ! I have the following situation: User clicks on a button that will fetch…
-
0
votes1
answer101
viewsFormat object with object array in properties - variable scope problem
Good morning, I have a problem returning from a webservice, I do a query to get Categories, and then another to get the items from that category. The goal is to assemble a return in the pattern: {…
-
0
votes1
answer395
viewsI cannot access the data using the fetch API
I have a URL that returns data in JSON: [ { "id": 21, "solicitante": "Joao", "chamado": "coisa aqui no lab" }, { "id": 22, "solicitante": "Maria", "chamado": "projetor deu pau" } ] On another page,…
-
0
votes1
answer199
viewsPromises Sequential - Node
I am trying to create a string of sequential Promises in Node.js and it is not running one at a time but all! You should perform as follows: Promise1 -> (then) -> Promise2 -> (then) ->…
-
0
votes0
answers119
viewsPromise inside Premomise does not wait Axios
Eae guys I’m having a problem, I get several objects where I mapped them, make an external query using the Axios and save your return. Let’s go to code: let savedClients =…
-
0
votes3
answers227
viewsHow to queue for Promises in Javascript?
I would like to know the best way to make a row of Promises in Javascript, so that the incoming Promise only runs after the previous Promise resolution. Example: var queue = [Promise1, Promise2];…