-3

I want to fetch data from a API link by using java script. I want to do this in only pure javascript.

Dhamu
  • 129
  • 1
  • 1
  • 11

1 Answers1

1

Use JavaScript function:

var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() { 
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
        callback(xmlHttp.responseText);
}
xmlHttp.open("GET", url, true); 
xmlHttp.send(null);
Prabhas Nayak
  • 282
  • 1
  • 4