{"action":"created","issue":{"url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/15","labels_url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/15/comments","events_url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/15/events","html_url":"https://github.com/codeforhuntsville/Frontier/pull/15","id":74099493,"number":15,"title":"small fix to client's fetch error handling","user":{"login":"syjulian","id":9344463,"avatar_url":"https://avatars.githubusercontent.com/u/9344463?v=3","gravatar_id":"","url":"https://api.github.com/users/syjulian","html_url":"https://github.com/syjulian","followers_url":"https://api.github.com/users/syjulian/followers","following_url":"https://api.github.com/users/syjulian/following{/other_user}","gists_url":"https://api.github.com/users/syjulian/gists{/gist_id}","starred_url":"https://api.github.com/users/syjulian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syjulian/subscriptions","organizations_url":"https://api.github.com/users/syjulian/orgs","repos_url":"https://api.github.com/users/syjulian/repos","events_url":"https://api.github.com/users/syjulian/events{/privacy}","received_events_url":"https://api.github.com/users/syjulian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-07T19:28:57Z","updated_at":"2015-05-07T23:39:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/codeforhuntsville/Frontier/pulls/15","html_url":"https://github.com/codeforhuntsville/Frontier/pull/15","diff_url":"https://github.com/codeforhuntsville/Frontier/pull/15.diff","patch_url":"https://github.com/codeforhuntsville/Frontier/pull/15.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/comments/100047244","html_url":"https://github.com/codeforhuntsville/Frontier/pull/15#issuecomment-100047244","issue_url":"https://api.github.com/repos/codeforhuntsville/Frontier/issues/15","id":100047244,"user":{"login":"syjulian","id":9344463,"avatar_url":"https://avatars.githubusercontent.com/u/9344463?v=3","gravatar_id":"","url":"https://api.github.com/users/syjulian","html_url":"https://github.com/syjulian","followers_url":"https://api.github.com/users/syjulian/followers","following_url":"https://api.github.com/users/syjulian/following{/other_user}","gists_url":"https://api.github.com/users/syjulian/gists{/gist_id}","starred_url":"https://api.github.com/users/syjulian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syjulian/subscriptions","organizations_url":"https://api.github.com/users/syjulian/orgs","repos_url":"https://api.github.com/users/syjulian/repos","events_url":"https://api.github.com/users/syjulian/events{/privacy}","received_events_url":"https://api.github.com/users/syjulian/received_events","type":"User","site_admin":false},"created_at":"2015-05-07T23:39:29Z","updated_at":"2015-05-07T23:39:29Z","body":"Before, when I would get a 500 error, this if-check wasn't being hit on public/app/index.js\r\n```\r\nif (response.statusCode < 200 || response.statusCode >= 300) {\t\t\r\n  throw new Error(response.statusText);\t\t\r\n}\r\n```\r\nIt turns out `response` doesn't have a `statusCode` property but just `status`\r\n\r\nSo changed that to check for `status` instead.\r\n\r\nI also noticed that the object here that is being sent by the express server from lib/routes/restaurants.js on a 500 error\r\n```\r\nif (!googleApiKey) {\r\n    res.status(500).send({\r\n      error: 'internal server error',\r\n      statusCode: 500,\r\n      description: 'server not configured for restaurant lookup'\r\n    });\r\n```\r\nisn't on `response` when doing the callback for `fetch()` in public/app/index.js. I looked at the fetch polyfill documentation, and it showed that I would need to call `response.json()` to return a promise that resolves to the object.\r\n\r\nI extracted out the checking of the `status` to `getStatus()` and the returning of the `response.json()` to `getJson()`. I tried to make it look like the way `fetch()` was used in its documentation.\r\n\r\nThis was how I understood things. I hope it made sense."}}