https://github.com/cloudhead/pilgrim
a JSON consuming JavaScript XHR client for the browser
https://github.com/cloudhead/pilgrim
Last synced: 11 months ago
JSON representation
a JSON consuming JavaScript XHR client for the browser
- Host: GitHub
- URL: https://github.com/cloudhead/pilgrim
- Owner: cloudhead
- License: mit
- Created: 2010-02-15T04:52:14.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2011-04-27T21:36:05.000Z (almost 15 years ago)
- Last Synced: 2025-03-26T09:12:04.770Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 15
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pilgrim
=======
JavaScript XHR client for the browser. JSON powered.
synopsis
--------
var client = new(pilgrim.Client)();
GET /people/42?age=45
client.path('/people/42').get({ age: 45 }, function (e, data) {
if (e) {
// Handle error
} else {
// Handle success
}
});
PUT /people/47/articles
client.path('/people/47/articles').put({
title: "Beast of the East",
body: "...",
tags: ['fiction']
}, function (e, res) {
// Handle response
});
using extensions
----------------
var client = new(pilgrim.Client)({ extension: '.json' });
GET /people/42.json
client.resource('/people/42').get();
POST /people/42.json/children
client.resource('/people/42').path('children').post();
GET /people/42
client.path('/people/42').get();
specifying a host
-----------------
var client = new(pilgrim.Client)('http://api.domain.com');
specifying headers
------------------
var client = new(pilgrim.Client)({ headers: { 'X-Header': 'pilgrim' } });