Skip to content

Commit

Permalink
Document fetch usage with Browserify — and switch suggested Promise…
Browse files Browse the repository at this point in the history
… library to one with a CommoJS API more similar to Fetch.
  • Loading branch information
matthew-andrews committed Oct 30, 2014
1 parent 430d871 commit 5a8b3cf
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ bower install fetch
You'll also need a Promise polyfill for older browsers.

```sh
$ bower install es6-promise
$ bower install native-promise-only
```

This can be also be installed with `npm`.
Expand All @@ -24,6 +24,35 @@ This can be also be installed with `npm`.
$ npm install github/fetch --save
```

### Using Fetch with Browserify and npm

```js
require('native-promise-only');
require('fetch');
```

Note: if you install **fetch** with npm you won't be able to specify a fuzzy
version or range of versions for **fetch** in your `package.json` as npm does
not support installing fuzzy versions from modules not published on their
registry.

Instead, you can choose ot install **fetch** at an exact specific version by
changing `package.json` to:

```json
...
"fetch": "https://github.com/github/fetch/archive/v0.1.0.tar.gz
...
```

Alternatively, if you would prefer to install **fetch** at a fuzzy version
you can install it via bower to install it and use the [debowerify transform](https://github.com/eugeneware/debowerify).

Full worked examples of these two approaches to using **fetch** in Browserify are avalable:

- [Fetch API + Browserify](https://github.com/matthew-andrews/fetch-browserify-demo)
- [Fetch API + Browserify + Bower](https://github.com/matthew-andrews/fetch-browserify-bower-demo)

## Usage

The `fetch` function supports any HTTP method. We'll focus on GET and POST
Expand Down

0 comments on commit 5a8b3cf

Please sign in to comment.