Skip to content

Instantly share code, notes, and snippets.

@nagyv
Created March 17, 2012 16:48
Show Gist options
  • Save nagyv/2062210 to your computer and use it in GitHub Desktop.
Save nagyv/2062210 to your computer and use it in GitHub Desktop.
Creating JSON request browser with Tobi
var tobi = require('tobi'),
browser = tobi.createBrowser(8000, "localhost");
json_browser = (function(){
var json_header = {headers:
{
"Accept": "application/json",
"X-Requested-With": "XMLHttpRequest"
}
};
var json_method = function(method){
return function(path, options, callback){
if(!callback) {
callback = options;
options = {};
}
browser[method](path, _.defaults(options, json_header), callback);
};
};
return {
get: json_method('get'),
post: json_method('post'),
put: json_method('put'),
delete: json_method('delete')
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment