hidden-sapphireH
Refine2y ago
3 replies
hidden-sapphire

Refecth query on error using useForm in REST and antd

I have this:
    const { form, formProps, saveButtonProps, onFinish, queryResult } = useForm({
        id,
        action: RESOURCES_ACTION_EDIT,
        resource: RESOURCES.COMPARISONS,
        onMutationSuccess: () => {
            const message = translate("common.success");
            const description = translate("pages.pricingAuditComparisions.edit.success");
            notification.success({ message, description });
        },
        onMutationError: () => {
            const message = translate("common.error");
            const description = translate("pages.pricingAuditComparisions.edit.error");
            notification.error({ message, description });
        },
    });

And want to check when is error to refetch data if is a 401
    if (queryResult?.isError && queryResult?.isFetched && queryResult?.failureReason?.statusCode === 401) {
        console.log('401');

        refect()
    }
Was this page helpful?