{"action":"created","issue":{"url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/58","labels_url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/58/comments","events_url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/58/events","html_url":"https://github.com/mizzao/meteor-user-status/issues/58","id":63284893,"number":58,"title":"Exception in template helper: TypeError: Cannot read property '' of undefined","user":{"login":"sangyoo91","id":8974551,"avatar_url":"https://avatars.githubusercontent.com/u/8974551?v=3","gravatar_id":"","url":"https://api.github.com/users/sangyoo91","html_url":"https://github.com/sangyoo91","followers_url":"https://api.github.com/users/sangyoo91/followers","following_url":"https://api.github.com/users/sangyoo91/following{/other_user}","gists_url":"https://api.github.com/users/sangyoo91/gists{/gist_id}","starred_url":"https://api.github.com/users/sangyoo91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangyoo91/subscriptions","organizations_url":"https://api.github.com/users/sangyoo91/orgs","repos_url":"https://api.github.com/users/sangyoo91/repos","events_url":"https://api.github.com/users/sangyoo91/events{/privacy}","received_events_url":"https://api.github.com/users/sangyoo91/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-20T19:11:00Z","updated_at":"2015-03-20T21:26:55Z","closed_at":null,"body":"```\r\nException in template helper: TypeError: Cannot read property 'online' of undefined\r\n    at Object.Template.answerItem.helpers.userStatus (http://localhost:3000/client/template/answers/answer_item.js?96f2d610d91b6621c436db2b7d6dce712c8ecd7a:38:53)\r\n    at bindDataContext (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:16)\r\n    at Blaze._wrapCatchingExceptions (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:16)\r\n    at Spacebars.call (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:18)\r\n    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:108:25)\r\n    at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:112:39)\r\n    at Template.answerItem.HTML.DIV.HTML.DIV.HTML.DIV.HTML.DIV.HTML.IMG.class (http://localhost:3000/client/template/answers/template.answer_item.js?a264a2f5b7e515e37ccef05b21702c2820d9e9ae:30:69)\r\n    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)\r\n    at Blaze._HTMLJSExpander.def.visitAttribute (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1971:21)\r\n    at HTML.TransformingVisitor.def.visitAttributes (http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:228:44)\r\n```\r\n\r\nI am getting this error...\r\n\r\nMy code is running properly so I left it. However, it was getting hard to read my browser console for other errors so I seek help!\r\n\r\n```\r\nuserStatus: function() {\r\n\t\t// if (Meteor.users.findOne({_id:this.userId}).status.idle)\r\n\t\t// \treturn \"user-border-idle\"\r\n\t\tif (Meteor.users.findOne({_id:this.userId}).status.online )\r\n\t\t\treturn \"user-border-online\"\r\n\t\telse\r\n\t\t\treturn null\r\n\t},\r\n\r\n\t//Show user status in text next to username\r\n\tisonline: function() {\r\n\t\tif (Meteor.users.findOne({_id:this.userId}).status.online)\r\n\t\t\treturn \"is online\"\r\n\t\telse \r\n\t\t\treturn null\r\n\t},\r\n```\r\n\r\nThis is my helper . I keep getting errors for these snippets. But code works as expected..."},"comment":{"url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/comments/84153162","html_url":"https://github.com/mizzao/meteor-user-status/issues/58#issuecomment-84153162","issue_url":"https://api.github.com/repos/mizzao/meteor-user-status/issues/58","id":84153162,"user":{"login":"jhuenges","id":7192165,"avatar_url":"https://avatars.githubusercontent.com/u/7192165?v=3","gravatar_id":"","url":"https://api.github.com/users/jhuenges","html_url":"https://github.com/jhuenges","followers_url":"https://api.github.com/users/jhuenges/followers","following_url":"https://api.github.com/users/jhuenges/following{/other_user}","gists_url":"https://api.github.com/users/jhuenges/gists{/gist_id}","starred_url":"https://api.github.com/users/jhuenges/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhuenges/subscriptions","organizations_url":"https://api.github.com/users/jhuenges/orgs","repos_url":"https://api.github.com/users/jhuenges/repos","events_url":"https://api.github.com/users/jhuenges/events{/privacy}","received_events_url":"https://api.github.com/users/jhuenges/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T21:26:55Z","updated_at":"2015-03-20T21:26:55Z","body":"I guess it works, because it is re-run many times. And at some point the staus.online field is found. So with the little fix we simple avoid the cases in which a) the user b) user.status or c) user.status.online is not known. "}}