i need to get a state from redux, to use it on API call inside the saga file.
i checked about the select API. but its a problem here.
i want to use one function just for the API call. to run this function i need to get the current state from redux. and than put it inside the generator function, i didnt succeed to use the select.
async function getApi(){
// GET THE STATE IN THE NEXT LINE
try{
const callByCity = await fetch(`https://www.test.com/APICALL${REDUX STATE}...
`)
const result= await callByCity.json()
return result
} catch(error) {
console.log(error.message)
}
}
function* fetchMainCity(action){
try{
const mainCity = yield call(getApi);
yield put({ type: "GET_CITY_SUCCESS", result: result})
} catch (e) {
yield put({type: "GET_CITY_FAILED", message: "Sorry, We Have A Problem."})
}
}