moderate-tomatoM
Refine3y ago
21 replies
moderate-tomato

How can I customize useRegister onSuccess error toast notification message?

This is the refine V4 source code for useRegister hook. There is error handling, which by default throws up a popup with the error message.
onSuccess: async ({ success, redirectTo, error }) => {
            if (success) {
                close?.("register-error");
            }

            if (error || !success) {
                open?.(buildNotification(error));
            }


How can I customize the popup message?
Now this error message comes from the backend:

common.emailAlreadyUsed: {"response":{"errors":[{"message":"common.emailAlreadyUsed"}],"data":null,"status":200,"headers":{"map":{"content-length":"63","content-type":"application/json; charset=utf-8"}}},"request":{"query":"\n mutation Mutation(\n $email: String!\n $password: String!\n $company: String!\n $firstName: String!\n $lastName: String!\n $industry: String!\n $skipEmailProviderValidation: Boolean!\n ) {\n register(\n registerUserInput: {\n email: $email\n password: $password\n company: $company\n firstName: $firstName\n lastName: $lastName\n industry: $industry\n skipEmailProviderValidation: $skipEmailProviderValidation\n }\n ) {\n email\n id\n }\n }\n","variables":{"email":"t@t.com","password":"1212","company":"vv","firstName":"vvv","lastName":"vvv","industry":"1","skipEmailProviderValidation":true}}}
Was this page helpful?