XMLHttpRequest API

Var request = new XMLHttpRequest();
request.onreadystatechange = (e) => {
  if (request.readyState !== 4) {
    return;
  }

  if (request.status === 200) {
    console.log('success', request.responseText);
  } else {
    console.warn('error');
  }
};

request.open('GET', 'https://mywebsite.com/endpoint/');
request.send();

Additional information

  • The security model for XMLHttpRequest is different than on web as there is no concept of CORS in native apps.

Related concepts

XMLHttpRequest API

XMLHttpRequest API — Structure map

Clickable & Draggable!

XMLHttpRequest API — Related pages: