knucklebone.js
Lightweight AJAX library for the client, intended for JSON API’s
Overview of Knucklebone
Available Methods:
get()getJson()post()postJson()
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 responseserror- 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
Why the name “knucklebone”?
This is why.