simple-get-es5
Simplest way to make http get requests, with an ES5 polyfill.
features
This module is designed to be the lightest possible wrapper on top of node.js http
, but supporting:
- follows redirects
- automatically handles gzip/deflate responses
- supports HTTPS
- supports convenience
url
key so there's no need to useurl.parse
on the url when specifying options
All this in < 100 lines of code.
install
npm install simple-get
usage
Note, all these examples also work in the browser with browserify.
simple GET request
Doesn't get easier than this:
var get =
even simpler GET request
If you just want the data, and don't want to deal with streams:
var get = get
POST, PUT, PATCH, HEAD, DELETE support
For POST
, call get.post
or use option { method: 'POST' }
.
var get = var opts = url: 'http://example.com' body: 'this is the POST body'get
A more complex example:
var get =
JSON
You can serialize/deserialize request and response with JSON:
var get = var opts = method: 'POST' url: 'http://example.com' body: key: 'value' json: trueget
Forms
You can send application/x-www-form-urlencoded
form data:
var get = var opts = method: 'POST' url: 'http://example.com' form: key: 'value' get
license
MIT. Copyright (c) Feross Aboukhadijeh.