T
TanStack16mo ago
foreign-sapphire

Request blocked status code for useMutation in Tanstack Query for Updating Data

I'm facing an issue with using useMutation in Tanstack Query to update a single row of data in my React application. The goal is to update patient data using a form and handle optimistic updates. However, I'm encountering an error which is forbidden or block request so please solve with me . ## INTERFACE CODE interface Patient { id: string; patientName: string; patientGender: string; patientDob: string; patientAddress: string; phoneNo: string; } ## USEMUTATION CODE const mutation = useMutation(updatePatient, { onSuccess: () => { queryClient.invalidateQueries(['patient', patient.id]); message.success('Patient updated successfully'); }, onError: () => { message.error('Error updating patient'); }, }); ## ONFINISH METHOD const onFinish = (values: any) => { const updatedPatient = { ...values, patientDob: values.patientDob.format('YYYY-MM-DD'), }; mutation.mutate({ id: patient.id, ...updatedPatient }); };
1 Reply
fascinating-indigo
fascinating-indigo16mo ago
Hello What is the error message?

Did you find this page helpful?