# xhr **Repository Path**: mirrors_michaelrhodes/xhr ## Basic Information - **Project Name**: xhr - **Description**: a little module that simplifies working with XMLHttpRequest objects (226 B) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-03-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xhr xhr is a little module that simplifies working with XMLHttpRequest objects [![build status](https://travis-ci.org/michaelrhodes/xhr.svg?branch=master)](https://travis-ci.org/michaelrhodes/xhr) ## install ```sh npm install michaelrhodes/xhr#2.0.0 ``` ### use ```js var xhr = require('xhr') // Basic async // ··········· xhr('GET /something', function (err) { err ? console.error('Status:', err.message) : console.log(this.responseText) }) // Less basic async // ················ var req = xhr('GET /something.json') // `req` is an XMLHttpRequest req.setRequestHeader('Accept', 'application/json') // with a fancy new `send` method req.send(function (err) { err ? console.error('Status:', err.message) : console.log(JSON.parse(this.responseText)) }) // Sending data // ············ var req = xhr('POST /something') var data = new FormData data.append('some', 'data') req.send(data, function (err) { err ? console.error('Status:', err.message) : console.log(this.responseText) }) // Basic sync // ·········· var req = xhr('GET /something', true) var res = req.send() console.log(res.responseText || res.status) ``` ### obey [MIT](http://opensource.org/licenses/MIT)