Skip to content

An extremely simple Javascript library for interacting with RESTful web services.

License

Notifications You must be signed in to change notification settings

cpicon92/rest.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

rest.js

An extremely simple Javascript library for interacting with RESTful web services that has no dependencies. It does automatic marshalling and unmarshalling of Javascript objects and JSON documents, and supports file uploads as well.

Usage

var rest = new Rest("/api");

//make PUT request (to URL "/api/resource")
rest.put("resource", {"something": "hello"})

//make GET request
rest.get("resource").done(function(resource) {
	//responded with 20x, you now have access to the resource
}).err(function(code, message) {
	//responded with error code
});

//upload file with POST
var input = document.querySelector("input[type=file]"),
file = input.files[0];
//set the the overrideType property on the file to change the Content-type header
file.overrideType = "application/json";
api.post("resource", file).done(function() {
	//file contents have been posted
}).err(function(code, message) {
	//responded with error code
});

About

An extremely simple Javascript library for interacting with RESTful web services.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published