Skip to content

Instantly share code, notes, and snippets.

@Marak
Forked from tim-smart/api.js
Created March 4, 2010 04:43
Show Gist options
  • Save Marak/321406 to your computer and use it in GitHub Desktop.
Save Marak/321406 to your computer and use it in GitHub Desktop.
exports.someMethod = function (arg1, arg2, callback) {
// Do this for safety's sake, people might accidentally send us an extra arg
arg1 = arguments[0];
arg2 = arguments[1];
callback = arguments[arguments.length - 1];
callback(null, 'win!');
};
// The call
{
"method": "someMethod",
"params": [ arg1, arg2 ],
"id": new Date().getTime()
}
// The response
{
"id": 12345, // The date we sent
"result": "win!",
"error": null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment