Skip to content

Instantly share code, notes, and snippets.

@marshallbrekka
Created December 10, 2014 18:13
Show Gist options
  • Save marshallbrekka/e5cb25d6e6c99dcb8dff to your computer and use it in GitHub Desktop.
Save marshallbrekka/e5cb25d6e6c99dcb8dff to your computer and use it in GitHub Desktop.
// Sample data used when put into a mocking mode
var exampleAccounts = [{
id: 1,
balance: 2254.86,
name: "JetBlue Card Orig"
}];
var accounts = new PersistentSpec("accounts/1/accounts", {
seq : true,
// proxy functions are called in place of network requests when in
// mocking mode
proxy : {
get : function(opts, promise) {
promise.resolve({"_control" : {result : "ok"}, response : proxyAccounts});
}
}
});
// Sample Usage
API.get(accounts, {id : 10}, function(serverResponse) {
if (serverResponse[0].id === 10) {
console.log("We have an account with id 10, just like we asked for");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment