Skip to content

Instantly share code, notes, and snippets.

@Oluwa-nifemi
Created March 29, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oluwa-nifemi/e97322e27ae83ccd328f469a1d0d9874 to your computer and use it in GitHub Desktop.
Save Oluwa-nifemi/e97322e27ae83ccd328f469a1d0d9874 to your computer and use it in GitHub Desktop.
Make requests using XMLHttpRequest
const makeRequest = async (method,url, body = null) => new Promise((resolve,reject) => {
const request = new XMLHttpRequest();
request.addEventListener('load',() => resolve(request));
request.addEventListener('error',() => reject(request));
request.open(method,url);
request.send(body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment