How to work with asynchronous javascript (node js)?

Good day! The GBR study, trying to overcome the asynchronous (async library)

console.log('start')

let userSearch = (cb)=>{
 connection.query("SELECT * FROM `users` WHERE `login` = ?", [data.login], (err, res)=>{
 if (err) throw err;
console.log(`result:`);
console.log(fld);
cb(fld);
})
}

console.log(userSearch());

console.log('end')


why when I try to work on kolbeco conclusion:
start
-end
-my data
March 19th 20 at 09:13
2 answers
March 19th 20 at 09:15
Solution
It is not necessary to deal with it, you can't win.

You need to understand and use. To understand is to read about the EventLoop.
To use - to read about, Promise, and async/await (in recent versions, or transpireren)
Urgent async/await ? - darby_Sipes commented on March 19th 20 at 09:18
Yes, same promises but beautifully written, without a promise-hell. - Willa.Zemlak commented on March 19th 20 at 09:21
March 19th 20 at 09:17
Solution
how to make a sequential operation, that would be when a particular query in the browser you don't have to wrap everything in a function and have colehill

use Promise's

Find more questions by tags Node.jsJavaScript