progressive-amaranthP
Refine4y ago
8 replies
progressive-amaranth

making custom errorNotification in mutate function under useDelete hook

I'm getting this error on trying to delete an entry.

Foreign key violation. update or delete on table "departments" violates foreign key constraint "sub_departments_department_id_fkey" on table "sub_departments": {"response":{"errors":[{"extensions":{"code":"constraint-violation","path":"$"},"message":"Foreign key violation.

I need to change this error into my own custom error message.

I'm using,

const { mutate } = useDelete();

under the mutate function,

onClick={
() =>
mutate({
id: record.id,
resource: "departments",
})
}

Here I've to pass errorNotification property and modify the above default notification message into my custom message.

@Omer
Was this page helpful?