{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/19","labels_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/19/comments","events_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/19/events","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/19","id":108322998,"number":19,"title":"Interceptor for Failed requests? ","user":{"login":"djds4rce","id":350933,"avatar_url":"https://avatars.githubusercontent.com/u/350933?v=3","gravatar_id":"","url":"https://api.github.com/users/djds4rce","html_url":"https://github.com/djds4rce","followers_url":"https://api.github.com/users/djds4rce/followers","following_url":"https://api.github.com/users/djds4rce/following{/other_user}","gists_url":"https://api.github.com/users/djds4rce/gists{/gist_id}","starred_url":"https://api.github.com/users/djds4rce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djds4rce/subscriptions","organizations_url":"https://api.github.com/users/djds4rce/orgs","repos_url":"https://api.github.com/users/djds4rce/repos","events_url":"https://api.github.com/users/djds4rce/events{/privacy}","received_events_url":"https://api.github.com/users/djds4rce/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-25T13:08:26Z","updated_at":"2015-09-26T21:59:42Z","closed_at":null,"body":"Shouldn't there be a global configuration to handle failed request instead of handling it in the error of every request? \r\nEg: I was handle session failures and instead of handling it in every request a global interceptor like Angular JS would be great. \r\nhttps://djds4rce.wordpress.com/2013/08/13/understanding-angular-http-interceptors/\r\n"},"comment":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/comments/143499293","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/19#issuecomment-143499293","issue_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/19","id":143499293,"user":{"login":"stanleyw","id":2966902,"avatar_url":"https://avatars.githubusercontent.com/u/2966902?v=3","gravatar_id":"","url":"https://api.github.com/users/stanleyw","html_url":"https://github.com/stanleyw","followers_url":"https://api.github.com/users/stanleyw/followers","following_url":"https://api.github.com/users/stanleyw/following{/other_user}","gists_url":"https://api.github.com/users/stanleyw/gists{/gist_id}","starred_url":"https://api.github.com/users/stanleyw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanleyw/subscriptions","organizations_url":"https://api.github.com/users/stanleyw/orgs","repos_url":"https://api.github.com/users/stanleyw/repos","events_url":"https://api.github.com/users/stanleyw/events{/privacy}","received_events_url":"https://api.github.com/users/stanleyw/received_events","type":"User","site_admin":false},"created_at":"2015-09-26T21:59:42Z","updated_at":"2015-09-26T21:59:42Z","body":"Hi Dayanand,\r\n\r\nWe considered the global error handler option when we implemented revocable sessions earlier, and decided against it.  We believe it makes your code more confusing to read/debug by a collaborator because the handler is not explicitly stated in the request code.  In addition, when the session token becomes invalid, the best error handling logic could be dependent on where the user is in the app; you may want to perform additional operations before forcing the user to log in again (e.g. perhaps save the currently unfinished document to local storage so it can be recovered after the user logs in again).\r\n\r\nIf you want to use the same error handling logic for all calls, we recommend the following pattern:\r\n\r\n    let globalErrorHandler = (error) => {\r\n      switch (error.code) {\r\n        case Parse.Error.INVALID_SESSION_TOKEN:\r\n          // Do whatever makes sense for invalid session\r\n        case Parse.Error.SOME_OTHER_ERROR_CODE:\r\n          // Handle another type of error\r\n        ...\r\n      }\r\n    }\r\n\r\n    // Then refer to this error handler from all network request calls in your app\r\n    obj.save().then(function(obj) { ... }, globalErrorHandler);"}}