# proquest

> Micro XHR wrapper using promises

Latest version **0.5.0** (published 2016-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install proquest
pnpm add proquest
yarn add proquest
bun add proquest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2016-10-11 |
| First published | 2014-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Parker Selbert |
| Maintainers | sorentwo |
| Keywords | xhr, ajax, request, promise |

## Links

- npm: https://www.npmjs.com/package/proquest
- Repository: github.com/sorentwo/proquest
- Homepage: https://github.com/sorentwo/proquest
- Issues: https://github.com/sorentwo/proquest/issues
- npm.io page: https://npm.io/package/proquest

## Dependencies (1)

- [es6-promise](https://npm.io/package/es6-promise.md) ^3.2.1

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2016-10-11
- 0.4.0 — 2016-09-09
- 0.3.0 — 2016-01-08
- 0.2.0 — 2015-01-23
- 0.1.1 — 2014-09-23
- 0.1.0 — 2014-08-12

## README

[![Build Status](https://travis-ci.org/sorentwo/proquest.svg?branch=master)](https://travis-ci.org/sorentwo/proquest)
[![npm version](https://badge.fury.io/js/proquest.svg)](http://badge.fury.io/js/proquest)

# Proquest (Promise Request)

Ultra light wrapper around XHR requests that returns Promises for composition.

## Installation

Designed for usage with CJS, namely via [browserify](browserify).

```bash
npm install proquest --save-dev
```

Then simply require it:

```javascript
var Request = require('proquest').Request;
```

## Usage

Proquest takes many of its design cues from [superagent](superagent), but in an
extremely paired back way.

```javascript
// Composing a request

var Request = require('proquest').Request;
var request = new Request('POST', 'https://example.com/things');

request
  .set('Accept', 'application/json')
  .set('Content-Type', 'application/json')
  .set('Authorization', 'token abcdefg1234567')
  .send({ name: 'New Thing', tags: ['a', 'b', 'c'] })
  .end()
  .then(function(response) {
    console.log('Success!', response.body);
  }, function(response) {
    console.log('Failure!', response.status);
  });
```

Often in the context of an application each request will share most headers.
This can be achieved easily with a `partial` request:

```javascript
// Compose a request using method, url, data, or header options.
var partial = Request.partial({
  header: {
    'Authorization' : 'token abc123'
    'Content-Type'  : 'application/json'
    'Accept'        : 'application/json'
  }
});

// Store the partial request for use throughout the application.
MyApp.request = partial;

// Elsewhere, use the request by invoking and completing it.
var request = partial({ method: 'HEAD', url: '/status' });
```

Inject a default error handler into all requests:

```javascript
Request.partial({
  catch: function(response) {
    console.log('failed with a status of: ' + response.status);
  }
});
```

## Notes

Proquest expects a modern XHR api underneath. That means IE8 and below isn't
going to work.

[browserify]: http://browserify.org/
[superagent]: http://visionmedia.github.io/superagent/

---
_Source: https://npm.io/package/proquest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
