I dispatch a custom action in react admin after a click on Upload button. POST request successfully works, but I don't know how to get a response. I log every reducer call, but no response data there. Example of my action:
export const UPLOAD_BY_BASE64 = 'UPLOAD_BY_BASE64';
export const uploadByBase64 = ({ file, path }) => ({
type: UPLOAD_BY_BASE64,
payload: { file, path },
meta: { fetch: CREATE, resource: 'images/upload/base64' }
});
According to the Handling Side Effects documentation, you can pass a callback to the meta attribute in order to retrieve the response payload:
export const uploadByBase64 = ({ file, path }) => ({
type: UPLOAD_BY_BASE64,
payload: { file, path },
meta: {
fetch: CREATE,
resource: 'images/upload/base64',
callback: ({ payload, requestPayload }) => {
// payload = response payload
},
},
});