w3c-xmlhttprequest-plus

2.2.0 • Public • Published

w3c-xmlhttprequest-plus Build Status

w3c-xmlhttprequest-plus is a fork of w3c-xmlhttprequest which adds the following features:


Server-side XMLHttpRequest like W3C spec for Node.

This library is still in development. We are recruiting contributors and your pull requests.

Install

$ npm install w3c-xmlhttprequest-plus

Example

Simple GET request

var XMLHttpRequest = require('w3c-xmlhttprequest-plus').XMLHttpRequest;

var client = new XMLHttpRequest();
client.open('GET', 'http://example.com/');
client.addEventListener('load', function(event) {
  console.log('HTTP Request OSHIMAI.');
}, false);
client.send();

Parse JSON response

var XMLHttpRequest = require('w3c-xmlhttprequest-plus').XMLHttpRequest;

var client = new XMLHttpRequest();
client.open('GET', 'http://exmaple.com/data.json');
client.responseType = 'json';
client.addEventListener('load', function() {
  var data = client.response;
  if (data.meta.status !== 200) {
    return;
  }
  console.log(data.response.blog.title);
}, false);
client.send();

LICENSE

MIT License

/w3c-xmlhttprequest-plus/

    Package Sidebar

    Install

    npm i w3c-xmlhttprequest-plus

    Weekly Downloads

    1

    Version

    2.2.0

    License

    MIT

    Unpacked Size

    50.7 kB

    Total Files

    21

    Last publish

    Collaborators

    • mrstux