Server-side XMLHttpRequest like Living Standard for Node.
$ npm install w3c-xmlhttprequest
or
$ yarn add w3c-xmlhttprequest
import { XMLHttpRequest } from 'w3c-xmlhttprequest';
const client = new XMLHttpRequest();
client.open('GET', 'https://example.com/');
client.addEventListener('load', () => {
console.log('Received an HTTP response.');
}
client.send();
import { XMLHttpRequest } from 'w3c-xmlhttprequest';
const client = new XMLHttpRequest();
client.open('GET', 'https://exmaple.com/data.json');
client.responseType = 'json';
client.addEventListener('load', () => {
const data = client.response;
if (data.meta.status !== 200) return;
console.log(data.response.blog.title);
});
client.send();