score:4
Accepted answer
just pass it with the action. the parts to be changed:
actions
export function getdata(id) {
return { type: "data_requested", payload:{id} };
}
saga
function* workersaga(action) {
try {
const payload = yield call(getdata,action.payload.id);
yield put({ type: "data_loaded", payload });
} catch (e) {
yield put({ type: "api_errored", payload: e });
}
getdata
export function getdata(input_id) {
return axios
.get(global.baseurl,{id:input_id})
.then(response => {
console.log("response data:", response.data);
return response.data;
})
.catch(error => {
console.log(
"123-------------network error to be solved--------------------"
);
return error;
});
}
you might need to change some more stuff to get a fully working code but this is the general way to achieve what you want.
Source: stackoverflow.com
Related Query
- How to Pass an ID to API call using redux saga?
- How to migrate api call wrapper from a redux thunk to redux saga
- How to wait for action and API call to complete using redux saga?
- how to pass string params in Get call of API using axios in Reactjs
- How to get specific fields from an api fetch using redux saga
- How to test api call in Redux Saga properly as a unit?
- how to make api call from external file using axios and callbacks and pass param in react
- componentWillReceiveProps method doesn't run anymore when using redux to call api
- Using an API call in ComponentDidMount to update Redux store makes my component render twice
- How to make the API call and display it in React JS using React Table and Axios?
- How to generate a unique id automatically for the data that is posted to an API server using axios library in redux
- How to change url after successful api call in saga
- How to pass data from one component to another while using API in reactjs
- how to call a redux saga generator function?
- How to await a setState call finishing when using useState hook that immediately needs that state to make an API call?
- How to post data to an API server using axios library in redux
- How to trap HTTP 4xx errors when using Redux Toolkit async REST API pattern?
- How to pass Dispatch to action when using redux form
- How to make API calls using React, Redux in TypeScript
- How to start a redux saga watcher using runSaga
- How to make common API call function using fetch
- How to Assign react redux state api get data using axios
- How to call functions with API calls in an action using Redux-hooks useDispatch from component?
- how to pass array in grpc call using reactjs
- How to make aspecific API call from within a Line Chart class in ReactJS using react-chartjs-2?
- React Redux how to pass data from input to rest api
- How to pass props from container component to redux form(component) - react using typescript
- How to filter records from an api server according to some specific properties in redux using axios
- React App Using the same function in two places but the API call is different. How do I force it to use the root everytime?
- How to pass types to a functional component in react using redux connect
More Query from same tag
- JSON object update giving strange result
- How to put back HTMLElement into React component after the was (re)moved without React
- JSON Parse error: Unrecognized token '!' - error caught by Sentry
- AgGrid rendering blank
- Formik + Material UI bug when i submit form and try to change the values
- Maintain background image responsiveness regardless of screen size
- difference between preset-react and react in babel
- TypeError: Cannot read property 'onMouse' of undefined React Class Component
- How to display base64 images from array in React Native
- including external javascript in Gatsby using Helmet
- React styled-component with Typescript, types error
- Getting the updated state after an action is dispatched in redux
- How can I add an undo button on my toast notification?
- Getting an error when trying to trigger a function for state change
- Why Route tag can't render the component in React?
- How to use if within a map return?
- Modifying a deep nested state in Redux
- React state updating without reason
- Filter search with ReactJs and mobx
- TypeError: Cannot read property 'createEvent' of null React Apollo testing
- Child to trigger parent function with parameters
- underline only half of the word in reactjs and material ui?
- PageSpeed Insights diagnostic "Ensure text remains visible during webfont load"
- Problem with Reducer that contains few different values
- How to send body data and headers with axios get request?
- How to enable proxy in react-slingshot (by coryhouse) so I can call my Django REST APIs?
- How should I update the Redux state in my React App?
- how to copy color in clipboard , reactjs
- The "Can't perform a React state update on an unmounted component" error
- React Material UI Drawer — Sliding Transition not working