browser-request / 0.3.3 last updated 2 years ago created on Dec 21st 2011
Install
npm install --save browser-request
Clone
git clone git@github.com:iriscouch/browser-request.git
dependencies
No dependencies listed.
maintainers
versions
9 total
| 0.3.3 | 2 years ago | jhs |
| 0.3.2 | 2 years ago | jhs |
| 0.3.1 | 3 years ago | jhs |
| 0.3.0 | 3 years ago | jhs |
| 0.2.1 | 3 years ago | jhs |
| 0.2.0 | 4 years ago | jhs |
| 0.1.0 | 5 years ago | jhs |
| 0.1.0-beta2 | 5 years ago | jhs |
| 0.1.0-beta1 | 5 years ago | jhs |
readme
Browser Request: The easiest HTTP library you'll ever see
Browser Request is a port of Mikeal Rogers's ubiquitous and excellent [request][req] package to the browser.
Jealous of Node.js? Pining for clever callbacks? Request is for you.
Don't care about Node.js? Looking for less tedium and a no-nonsense API? Request is for you too.
Examples
Fetch a resource:
Send a resource:
To work with JSON, set options.json to true. Request will set the Content-Type and Accept headers, and handle parsing and serialization.
Or, use this shorthand version (pass data into the json option directly):
Convenient CouchDB
Browser Request provides a CouchDB wrapper. It is the same as the JSON wrapper, however it will indicate an error if the HTTP query was fine, but there was a problem at the database level. The most common example is 409 Conflict.
See the [Node.js Request README][req] for several more examples. Request intends to maintain feature parity with Node request (except what the browser disallows). If you find a discrepancy, please submit a bug report. Thanks!
Usage
Browserify
Browser Request is a [browserify][browserify]-enabled package.
First, add browser-request to your Node project
Next, make a module that uses the package.
To build this for the browser, run it through browserify.
Deploy example-built.js to your web site and use it from your page.
UMD
browser-request is UMD wrapped, allowing you to serve it directly to the browser from wherever you store the module.
You may also use an AMD loader by referencing the same file in your loader config.
License
Browser Request is licensed under the Apache 2.0 license.
