Skip to content

Commit

Permalink
Describe how to use browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Mar 30, 2012
1 parent cd208fa commit b8bb8dd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Expand Up @@ -67,6 +67,39 @@ See the [Node.js Request README][req] for several more examples. Request intends

# Usage

## Browserify

Browser Request is a [browserify][browserify]-enabled package.

First, add `browser-request` to your Node project

$ npm install browser-request

Next, make a module that uses the package.

```javascript
// example.js - Example front-end (client-side) code using browser-request via browserify
//
var request = require('browser-request')
request('/', function(er, res) {
if(!er)
return console.log('browser-request got your root path:\n' + res.body)

console.log('There was an error, but at least browser-request loaded and ran!')
throw er
})
```

To build this for the browser, run it throubh browserify.

$ browserify --entry example.js --outfile example-built.js

Deploy `example-built.js` to your web site and use it from your page.

```html
<script src="example-built.js"></script> <!-- Runs the request, outputs the result to the console -->
```

## Ender

Browser Request is an [Ender][ender] package. If you don't have Ender, install it, and don't ever look back.
Expand Down

0 comments on commit b8bb8dd

Please sign in to comment.