1.1.2 • Published 9 years ago

knucklebone v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

knucklebone.js

Lightweight AJAX library for the client, intended for JSON API's

GitHub version

Overview of Knucklebone

Available Methods:

  • get()
  • getJson()
  • post()
  • postJson()
  • postUrlencoded()
knucklebone.getJson('path/to/file')
.success(json => console.log(json))
.error((err, res) => console.error(err));
knucklebone.postJson('url/path', jsonData)
.success(res => console.log(res))
.error((err, res) => console.error(err));

There are 2 methods that can handle the response(s):

  • success - receives any succesful responses
  • error - receives any errored responses and timeout responses

These methods are all chained onto the call--promise style. They both take a callback.

knucklebone.getJson("path/to/file")
.success(json => console.log(json))
.error((err, res) => console.error(err));

Get Parameters

Passing an object as a second parameter...

knucklebone.getJson("http://example.com", {
    name: "sam", token: "dn398fdh9eud0"
})

...would result in a query string of:

http://example.com?name=sam&token=dn398fdh9eud0

Headers

The third parameter passed to any knucklebone method can be an object of header info.

Example:

knucklebone.getJson("http://example.com", null, {
  withCredentials: true,
  'Content-Type': 'application/json;charset=UTF-8'
})

Why the name "knucklebone"?

This is why.

1.1.2

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago