V
V
valentine112016-11-03 17:35:55
MySQL
valentine11, 2016-11-03 17:35:55

The first three requests in the array disappear without a trace, hyadnt?

There is a code that pulls the API methods that make queries to the database.
Here is the code:

//сам запрос
var sendReq = function() {
    return request
        .get(apiUrl)
        .send(prepareArrayReq()) //внутри исполняется функция которая возвращает массив запросов, 6 штук
        .send(prepareArrayReq())//та же ф-я, но возвращает другой массив, 3 запроса
        .end((err, res) => {
            if (err || !res.ok) {
                console.log('Something was wrong! ' + err);
            } else {
                console.log('Sucess! ' + JSON.stringify(res));
            }
        });
};

The query array looks like this:
[ { jsonrpc: '2.0',
    method: 'someMethod',
    params: { one: 'one', two: 'true', three: 10},
    id: '0' },
  { jsonrpc: '2.0',
    method: 'someMethod',
    params: { one: 'one2', two: 'true', three: 9},
    id: '1' },
  { jsonrpc: '2.0',
    method: 'someMethod',
    params: { one: 'one3', two: 'true', three: 8},
    id: '2' },
  { etc},
...
  ]

When sending a request to the console, an array is displayed to check the correctness of the formation, and also the answer.
Problem: the first array has 6 requests, the second - 3. The output of the response to the console shows that the array with three requests is executed first, and then the last four requests from the first array are executed. The first three requests from the first array are simply not executed.
All queries are correct.
Why is this happening and how can I make sure that all requests are executed ??
UPD. The question has been changed.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question