I try to get data from the Pixabay service.
The request does not work (server response 0)
When in the request parameters I turn off the asynchrony through
xhr.open('GET', URL, false); request receives data.
How can I make an asynchronous request correctly?
PS Understood, the code that will be run after an asynchronous operation is performed must be included in the event handler readystatechange
xhr.onreadystatechange = function() { if (xhr.readyState == 4) { //код } }; or alternatively in the load event handler
xhr.onload = function() { console.log( xhr.responseText ); };