@@ -9,10 +9,7 @@ import {
99 takeLatest ,
1010} from "redux-saga/effects" ;
1111import * as Types from "../actions/types" ;
12- import {
13- GetDataFromServer ,
14- deleteService
15- } from "../service" ;
12+ import { GetDataFromServer , deleteService } from "../service" ;
1613
1714const baseUrl = "https://mern-article.herokuapp.com" ;
1815// const baseUrl = "http://localhost:5000";
@@ -34,7 +31,7 @@ function* fetchLoginUser(action) {
3431 } else {
3532 yield put ( {
3633 type : Types . LOGIN_USER_SERVER_RESPONSE_SUCCESS ,
37- result
34+ result,
3835 } ) ;
3936 }
4037 } catch ( error ) {
@@ -52,12 +49,12 @@ function* listArticles(action) {
5249 if ( result . error ) {
5350 yield put ( {
5451 type : Types . ARTICLE_LIST_ERROR_RESPONSE ,
55- result
52+ result,
5653 } ) ;
5754 } else {
5855 yield put ( {
5956 type : Types . ARTICLE_LIST_SUCCESS_RESPONSE ,
60- result
57+ result,
6158 } ) ;
6259 }
6360 } catch ( error ) {
@@ -74,12 +71,12 @@ function* getUser(action) {
7471 if ( result . error ) {
7572 yield put ( {
7673 type : Types . GET_USER_ERROR_RESPONSE ,
77- result
74+ result,
7875 } ) ;
7976 } else {
8077 yield put ( {
8178 type : Types . GET_USER_SUCCESS_RESPONSE ,
82- result
79+ result,
8380 } ) ;
8481 }
8582 } catch ( error ) {
@@ -96,12 +93,12 @@ function* getBookmarks(action) {
9693 if ( result . error ) {
9794 yield put ( {
9895 type : Types . GET_BOOKMARKS_ERROR_RESPONSE ,
99- result
96+ result,
10097 } ) ;
10198 } else {
10299 yield put ( {
103100 type : Types . GET_BOOKMARKS_SUCCESS_RESPONSE ,
104- result
101+ result,
105102 } ) ;
106103 }
107104 } catch ( error ) {
@@ -236,7 +233,7 @@ function* deleteArticleDetails(action) {
236233 const newData = yield call ( deleteService , formBody , deleteApi ) ; // Refer sample to api calls in remote.js file
237234 yield put ( {
238235 type : Types . DELETE_ARTICLE_SUCCESS ,
239- newData
236+ newData,
240237 } ) ; // pass in the id you updated and the newData returned from the API
241238 /// Other things can go here depending on what you want
242239 } catch ( e ) {
@@ -410,7 +407,7 @@ function* deleteArticleLike(action) {
410407 if ( result . error ) {
411408 yield put ( {
412409 type : Types . DELETE_LIKE_ARTICLE_ERROR_RESPONSE ,
413- result
410+ result,
414411 } ) ; // pass in the id you updated and the newData returned from the API
415412 } else {
416413 yield put ( {
@@ -433,12 +430,12 @@ function* getFollowers(action) {
433430 if ( result . error ) {
434431 yield put ( {
435432 type : Types . GET_FOLLOWERS_ERROR_RESPONSE ,
436- result
433+ result,
437434 } ) ;
438435 } else {
439436 yield put ( {
440437 type : Types . GET_FOLLOWERS_SUCCESS_RESPONSE ,
441- result
438+ result,
442439 } ) ;
443440 }
444441 } catch ( error ) {
@@ -455,12 +452,12 @@ function* getFollowing(action) {
455452 if ( result . error ) {
456453 yield put ( {
457454 type : Types . GET_FOLLOWING_ERROR_RESPONSE ,
458- result
455+ result,
459456 } ) ;
460457 } else {
461458 yield put ( {
462459 type : Types . GET_FOLLOWING_SUCCESS_RESPONSE ,
463- result
460+ result,
464461 } ) ;
465462 }
466463 } catch ( error ) {
@@ -494,6 +491,7 @@ function* followUser(action) {
494491 try {
495492 let formBody = { } ;
496493 formBody . user = action . follow_id ;
494+ const _id = action . user_id ;
497495 const postUrl = baseUrl + "/user/" + action . user_id + "/follow" ;
498496 const response = yield call ( GetDataFromServer , postUrl , "POST" , formBody ) ;
499497 const result = yield response . json ( ) ;
@@ -506,6 +504,7 @@ function* followUser(action) {
506504 yield put ( {
507505 type : Types . FOLLOW_USER_SUCCESS_RESPONSE ,
508506 result,
507+ _id,
509508 } ) ;
510509 }
511510 } catch ( error ) {
@@ -518,6 +517,7 @@ function* unFollowUser(action) {
518517 try {
519518 let formBody = { } ;
520519 formBody . user = action . unfollow_id ;
520+ const _id = action . user_id ;
521521 const postUrl = baseUrl + "/user/" + action . user_id + "/follow" ;
522522 const response = yield call ( GetDataFromServer , postUrl , "POST" , formBody ) ;
523523 const result = yield response . json ( ) ;
@@ -530,6 +530,7 @@ function* unFollowUser(action) {
530530 yield put ( {
531531 type : Types . UN_FOLLOW_USER_SUCCESS_RESPONSE ,
532532 result,
533+ _id,
533534 } ) ;
534535 }
535536 } catch ( error ) {
@@ -558,7 +559,7 @@ function* signUpUser(action) {
558559 } else {
559560 yield put ( {
560561 type : Types . SIGNUP_USER_SERVER_RESPONSE_SUCCESS ,
561- result
562+ result,
562563 } ) ;
563564 }
564565 } catch ( error ) {
@@ -616,4 +617,4 @@ export default function* rootSaga(params) {
616617 yield takeEvery ( Types . DELETE_LIKE_ARTICLE , deleteArticleLike ) ;
617618 yield takeEvery ( Types . GET_ARTICLES_LIKED , getArticlesLiked ) ;
618619 console . log ( "ROOT SAGA" ) ;
619- }
620+ }
0 commit comments