I have a simple saga. The Idea is to listen the action REQUESTS_OWNERSHIP_EDIT
to be dispatched from the store and run submit submitOwnerships(ownerships)
that is supposed to submit the ownership params to the server.
I'm confused about how to get the ownerships
value in the function dispatched from the saga.
Here it is my code:
// saga.js
import request from 'utils/request';
import { select, call, put, takeLatest } from 'redux-saga/effects';
import { editOwnerships } from './actions';
import { REQUESTS_OWNERSHIP_EDIT } from './constants';
export function* submitOwnerships(ownerships) {
// I would like to have here ownerships equals to the parameter passed to my action.
const requestURL = 'http://localhost:3001/';
try {
const art = yield call(request, requestURL, { method: 'POST', body: ownerships });
yield put(....);
} catch (err) {
yield put(....);
}
}
export default function* ownershipEdit() {
yield takeLatest(REQUESTS_OWNERSHIP_EDIT, submitOwnerships);
}
// actions.js
export function editOwnerships(ownerships) {
return {
type: REQUESTS_OWNERSHIP_EDIT,
ownerships,
};
}
I'm sure I'm missing something.