{"action":"opened","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/188","repository_url":"https://api.github.com/repos/yelouafi/redux-saga","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/188/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/188/events","html_url":"https://github.com/yelouafi/redux-saga/issues/188","id":140408001,"number":188,"title":"[Question] Handling chained promises / parsing fetch response","user":{"login":"tomauty","id":1112872,"avatar_url":"https://avatars.githubusercontent.com/u/1112872?v=3","gravatar_id":"","url":"https://api.github.com/users/tomauty","html_url":"https://github.com/tomauty","followers_url":"https://api.github.com/users/tomauty/followers","following_url":"https://api.github.com/users/tomauty/following{/other_user}","gists_url":"https://api.github.com/users/tomauty/gists{/gist_id}","starred_url":"https://api.github.com/users/tomauty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomauty/subscriptions","organizations_url":"https://api.github.com/users/tomauty/orgs","repos_url":"https://api.github.com/users/tomauty/repos","events_url":"https://api.github.com/users/tomauty/events{/privacy}","received_events_url":"https://api.github.com/users/tomauty/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-12T19:02:26Z","updated_at":"2016-03-12T19:02:26Z","closed_at":null,"body":"Hello. I'm really digging redux-saga, but have run into an issue with my response parsing. I just moved over to using fetch's `text()` and `json()` functions, which return promises, and now my `try/catch` blocks aren't working the way they used to. Here's an example.\r\n\r\nThe parser:\r\n```javascript\r\nexport function parseResponse(response : Object, emptyResponseExpected : ?boolean) : Promise {\r\n\tif (response && response.status) {\r\n\t\tif (response.status < 200 || response.status > 399) {\r\n\t\t\tconsole.log('[REJECT]', response);\r\n\t\t\treturn response.text().then((text) => Promise.reject(parseJSONResponse(text)));\r\n\t\t}\r\n\t\tconsole.log('[RESOLVE]', response);\r\n\t\treturn response.text().then((text) => Promise.resolve(parseJSONResponse(text)));\r\n\t}\r\n\tif (!response && !emptyResponseExpected) { return Promise.reject(response.status); }\r\n\tif (response && emptyResponseExpected) { return Promise.reject(response.status); }\r\n\treturn response.text().then((text) => Promise.resolve(parseJSONResponse(text)));\r\n}\r\n```\r\n\r\nThe saga:\r\n\r\n```javascript\r\nfunction* refreshToken() {\r\n\tconst authToken = yield select(token);\r\n\tconst config = { method: 'put', headers: { ...POST_HEADERS, Authorization: `Bearer ${authToken}` } };\r\n\ttry {\r\n\t\tconst response = yield call(callAPI, genRoute('/token'), config);\r\n\t\tyield put({ type: TOKEN_REFRESH_SUCCESS, response });\r\n\t} catch (error) {\r\n\t\tyield put({ type: TOKEN_REFRESH_FAILURE, error });\r\n\t}\r\n}\r\n```\r\n\r\nCallAPI, for reference:\r\n```javascript\r\nfunction* callAPI(route : string, config : Object, emptyResponseExpected : boolean = false) {\r\n\treturn fetch(route, config).then(response => {\r\n\t\treturn parseResponse(response, emptyResponseExpected);\r\n\t});\r\n}\r\n```\r\n\r\nThe console does output `[REJECT]`, but I still put the `TOKEN_REFRESH_SUCCESS` type, with an undefined response. Maybe I'm overcomplicating things, but any help would be appreciated. I hope I come to better understand sagas by posting this."}}