Created
April 21, 2014 22:36
-
-
Save laser/11158913 to your computer and use it in GitHub Desktop.
RPC Batch Errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Errors from Batch Request (Barrister) | |
initApp(function(err, TodoManager, BatchTodoManager) { | |
TodoManager.readTodos(function(err, todos) { | |
for (var i = 0, len = todos.length; i < len; i++) { | |
BatchTodoManager.deleteTodo(todos[i]['id']); | |
} | |
BatchTodoManager.send(function(err, results) { | |
var result, i, len; | |
for (i = 0, len = results.length; i < len; i++) { | |
result = results[i]; | |
if (result.error) { | |
alert(result.error.code); // will fire once, for the last todo | |
} | |
else { | |
console.log(result.result); // will output for as many todos as we had, minus 1 | |
} | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment