I am trying to call an API using XMLHttpRequest. The code is working fine but I am getting warning which reads :
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
I saw multiple posts on this portal with the same error and some possible solutions but I am unable to figure out whats the solution to fix it for my below code in Javascript.
var xhReq = new XMLHttpRequest();
xhReq.open("GET", api_url, false);
xhReq.send(null);
var jsonObject = JSON.parse(xhReq.responseText);
Side note: I am also a beginner to Javascript