import { call ,put} from "redux-saga/effects";
import { setLoading } from "../../component/loader/loaderSlice";
import { handleLogin } from "../../services/loginService";
export function* doUserLogin({payload}){
const {userName,password} =payload.user
try {
const response = yield call(handleLogin(userName,password));
//problem is here , when I am passing a valid user and password its not logging here
if(response.data){
console.log('Logge In',response);
}
console.log(response.data)
}catch (error) {
// its logging the response when I am getting error from server
if(error.response){
console.log(error.response.data)
}
}
}
authService.js
import axios from 'axios'
import { useSelector, useDispatch } from "react-redux";
export function handleLogin(userName,password){
console.log(userName)
const res= axios.request({
method:'post',
url:'http://localhost:8000/api/auth/login',
data:{
userName,
password
}
})
console.log(res);
return res;
}
authSaga.js
import {takeLatest} from 'redux-saga/effects'
import { handleLogin } from '../../component/login/loginSlice'
import { doUserLogin } from './authSaga'
export function* watcherSaga(){
yield takeLatest(handleLogin.type,doUserLogin)
}
rootSaga.js
When user is not valid,it is getting logged in error block,but for a valid user its not logging after the yield call(handleLogin(userName,password)) statement. Why its getting stuck there?