{"action":"closed","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/271","repository_url":"https://api.github.com/repos/yelouafi/redux-saga","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/271/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/271/events","html_url":"https://github.com/yelouafi/redux-saga/issues/271","id":150628008,"number":271,"title":"dispatch race condition","user":{"login":"stantoncbradley","id":5314103,"avatar_url":"https://avatars.githubusercontent.com/u/5314103?v=3","gravatar_id":"","url":"https://api.github.com/users/stantoncbradley","html_url":"https://github.com/stantoncbradley","followers_url":"https://api.github.com/users/stantoncbradley/followers","following_url":"https://api.github.com/users/stantoncbradley/following{/other_user}","gists_url":"https://api.github.com/users/stantoncbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/stantoncbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stantoncbradley/subscriptions","organizations_url":"https://api.github.com/users/stantoncbradley/orgs","repos_url":"https://api.github.com/users/stantoncbradley/repos","events_url":"https://api.github.com/users/stantoncbradley/events{/privacy}","received_events_url":"https://api.github.com/users/stantoncbradley/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-24T05:08:28Z","updated_at":"2016-04-24T16:13:59Z","closed_at":"2016-04-24T16:13:59Z","body":"Perhaps I misunderstand something and could use some advice... When I call my API from my saga, my dispatch method is fired before the request finishes.  What am I missing, or how should I handle this?\r\n\r\nMy saga:\r\n```\r\nfunction* storeUser(action) {\r\n  try {\r\n    const status = yield call(Storage.saveUser, action.profile, action.token);\r\n    yield put({type: \"STORE_USER_SUCCEEDED\", status: status});\r\n  } catch (e) {\r\n    yield put({type: \"STORE_USER_FAILED\", message: e.message})\r\n    console.log(e.message)\r\n  }\r\n}\r\n```\r\n\r\nMy API:\r\n```\r\nexport const connect = () => {\r\n  AsyncStorage.multiGet(['profile', 'token'], (err, stores) => {\r\n    const profile = JSON.parse(stores[0][1]);\r\n    const token = JSON.parse(stores[1][1]);\r\n    return fetch(API_ROOT + 'users/', {\r\n      method: 'POST',\r\n      headers: {\r\n        Authorization: \"Bearer \" + token.idToken,\r\n        Accept: 'application/json',\r\n        'Content-Type': 'application/json'\r\n      },\r\n      body: JSON.stringify( {\r\n        name: profile.name,\r\n        picture: profile.picture,\r\n        access_token: token.accessToken\r\n      })\r\n    })\r\n    .then((response) => response.text())\r\n    .then((responseText) => {\r\n      console.log(responseText);\r\n      return responseText;\r\n    })\r\n    .catch((error) => {\r\n      console.warn(error);\r\n      return error;\r\n    });\r\n  })\r\n}\r\n```"}}