Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Node.js HTTP Client
CoffeeScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Cakefile
ReadMe.md
package.json

ReadMe.md

Introduction

Shred is an HTTP client library that makes writing clients fun and easy.

// we'll omit this part in future examples
var Shred = require("shred")
  , shred = Shred.new()
  ;

shred.get({
  url: "http://shark.com/",
  headers: {
    accept: "application/json"
  },
  on: {
    response: function(response) {
      console.log(response.body.json.sessions.url);
    }
  }
});

The response was JSON, but Shred handles that for you because we specified application/json in the Accept header. So we're able to access it via response.body.json.

Here's another example:

shred.post({
  url: home.sessions.url
  headers: {
    accept: shark.types["1.0"].session,
    contentType: shark.types["1.0"].application
  },
  body: {
    key: "1234567890" // your application key
  },
  on: {
    201: function(response) {
      console.log(response.body.json.notifications.channels.url);
    }
  }
});
Something went wrong with that request. Please try again.