Take client from context
authorymh <ymh.work@gmail.com>
Mon, 19 Jun 2017 18:32:27 +0200
changeset 57 2e4e9f9ebc4f
parent 56 96543c395baa
child 58 f16a080e0bc4
Take client from context
client/src/sagas/index.js
--- a/client/src/sagas/index.js	Mon Jun 19 18:23:26 2017 +0200
+++ b/client/src/sagas/index.js	Mon Jun 19 18:32:27 2017 +0200
@@ -100,7 +100,7 @@
     try {
 
         const { username, password } = yield take(types.AUTH_LOGIN_REQUEST);
-        const client = context['client'];
+        const client = context.client;
         const response = yield client.post('/api/auth/login/', { username, password });
 
         localStorage.setItem('currentUser', JSON.stringify(response.user));
@@ -135,9 +135,10 @@
   }
 }
 
-function* watchUpdateSettings() {
+function* watchUpdateSettings(context) {
   while (true) {
     const { username, firstname, lastname } = yield take(types.USER_UPDATE_SETTINGS_ASYNC);
+    const client = context.client;
     try {
       yield client.put('/api/auth/user/', {
         username,
@@ -163,6 +164,6 @@
     watchLoginSubmit(),
     watchLoginRequest(context),
     watchStoreToken(),
-    watchUpdateSettings(),
+    watchUpdateSettings(context),
   ])
 }