Questions tagged as 'promises'

0
answers

Return of promise

Considering the example below: function retornaValor (){ return promiseQueveioDeAlgumaLib.then( function(oQueQueroRetornar){ return { sucesso: true, data : oQueQueroRetornar } }, function(opsAlgoErrado...
asked by 16.12.2016 / 19:48
1
answer

JavaScript Semaphores

How can I create semaphores in JavaScript? I have an asynchronous script that runs n times, I would like it when the n tasks terminate another task to be executed. I used normal access to a variable but this can cause race condition. Promise...
asked by 23.06.2017 / 15:21
1
answer

Promise Javascript

I have a scenario in which I make various Ajax calls to a WebApi and with the return I load controls from an application. I would like to create a single method to call the API, which would receive a parameter with the link, for example 'api...
asked by 28.02.2018 / 19:42
1
answer

Return of asynchronous methods javascript

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); }); What I wanted was to be able to do someth...
asked by 15.09.2017 / 01:53
1
answer

Access variable from within the scope of the 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', 'ServiceSecondary']; function ServiceMain(Service...
asked by 04.04.2017 / 15:41
0
answers

Problem with Promises in javascript (discord bot)

I'm not getting any way to make a part of the code that works with promises work. In the code, I do a check in arrays (obtained by a json) to know if youtube video is blocked or not, however, I need the rest of the method to wait for that part t...
asked by 11.10.2018 / 06:42
1
answer

Format object with array of objects in properties - variable scope problem

Good morning, I have a problem with returning a webservice, I make a query to get Categories, and then another to get the items in that category. The goal is to set a return on the pattern: { "categoryId" : 1, <--- resultad...
asked by 10.09.2018 / 03:19
1
answer

Angular4 wait for callback to API without timeout

If you can help me, please. I need to make a call in the API but there are a lot of data and I want Angular to wait for this term, at that moment I put a promise but it does not wait and as long as the API is handling the data on the NodeJS s...
asked by 23.07.2018 / 15:21
2
answers

Promise / Observable chaining in IONIC / Angular

Personal I am new to IONIC / Angular and I do not understand it yet very well Promise / Observable and would like a help! I have the following situation: User clicks a button that will fetch information from the phone's SQLite; A foreach i...
asked by 04.08.2018 / 01:59
0
answers

Node return page

I have the following code block server.get('/energy', (req, res, next) => { { const getScript = (url) => { return new Promise((resolve, reject) => { const http = require('http'), https = require('https') le...
asked by 15.06.2018 / 21:15