Get Particular Job Details Based On Jobid In Redux And Router
i have list of jobs for different job id. i have to fetch the particular job details based on job id. I have created action and reducer function for that. But, i am new to redux no
Solution 1:
If you want to asynchronous function like axios call with redux, you should use middleware like redux-saga
or redux-thunk
and so on.
I'll give you some example for using redux-thunk
make store
import thunkMiddleware from'redux-thunk';
import { createStore, applyMiddleware } from'redux';
import rootReducer from <your rootReducer path>
const createStoreWithMiddleware = applyMiddleware(
thunkMiddleware
)(createStore);
const store = createStoreWithMiddleware(rootReducer);
action.js
exportconstretrieveLocations = (jobId) => (dispatch) => {
axios.get(urlLoc+'/jobs/'+jobId).then(res => {
dispatch({
type: RETRIEVE_LOCATION,
payload: res.data.job.locations
});
});
};
Post a Comment for "Get Particular Job Details Based On Jobid In Redux And Router"