Answers for "make api request javascript"

2

create http request javascript

const Http = new XMLHttpRequest();
const url='https://jsonplaceholder.typicode.com/posts';
Http.open("GET", url);
Http.send();

Http.onreadystatechange = (e) => {
  console.log(Http.responseText)
}
Posted by: Guest on September-14-2020
4

using apis in javascript

// Create a request variable and assign a new XMLHttpRequest object to it.
var request = new XMLHttpRequest()

// Open a new connection, using the GET request on the URL endpoint
request.open('GET', url, true)

request.onload = function () {
  // Begin accessing JSON data here
}

// Send request
request.send()
Posted by: Guest on April-09-2021
1

http request javascript

function httpGetAsync(url, callback) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.onreadystatechange = function() { 
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
      callback(xmlHttp.responseText);
  }
  xmlHttp.open("GET", url, true); // true for asynchronous 
  xmlHttp.send(null);
}
Posted by: Guest on May-20-2020

Code answers related to "make api request javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language