w3c-xmlhttprequest
TypeScript icon, indicating that this package has built-in type declarations

3.0.4 • Public • Published

w3c-xmlhttprequest Node.js CI

Server-side XMLHttpRequest like Living Standard for Node.

Install

$ npm install w3c-xmlhttprequest

or

$ yarn add w3c-xmlhttprequest

Example

Simple GET request

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();

Parse JSON response

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();

LICENSE

MIT License

/w3c-xmlhttprequest/

    Package Sidebar

    Install

    npm i w3c-xmlhttprequest

    Weekly Downloads

    11,259

    Version

    3.0.4

    License

    MIT

    Unpacked Size

    448 kB

    Total Files

    21

    Last publish

    Collaborators

    • ykzts