I'm creating a React Admin project with a Drf Api, the thing is, when I update the image field of one of my models, it updates, and everything works, but throws the next error: "The dataProvider returned an empty response for 'update'.".
I checked at the network section in the development tools, and it does receive a response from the api
Here is the React Admin data provider code:
const dataProvider = drfProvider('http://127.0.0.1:8000')
const myDataProvider = {
...dataProvider,
update : (resource, params) => {
if(!params.data.image) {
return dataProvider.update(resource, params)
}
if (!params.data.image.rawFile) {
delete params.data.image
return dataProvider.update(resource, params)
}
return convertFileToBase64(params.data.image).then(image => {
dataProvider.update(resource, {
...params,
data : {
...params.data,
image : image
}
})
})
}
}
const convertFileToBase64 = file =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(file.rawFile);
});
export default myDataProvider; ```