register(values: TRegisterFormValues): Promise<TResponse | null>¶
The register
is an asynchronous method that allows to register a user. This method is also responsible for handling validation messages after the registration process occurs.
Input parameters¶
values¶
values
is a mandatory parameter of the TRegisterFormValues
type which represents an object of configuration parameters necessary to fire a register method. You can find out more about TRegisterFormValues object here.
Returned value¶
A returned value has a type of Promise<TResponse | null>
. You can read more about TResponse object here.
Event Bus events¶
This API method dispatches the following events with the Event Bus:
- authentication.registered - when the user registers
Example¶
In this example we make a AuthenticationApi
call to register a user.
useStorefront(async (storefront) => {
const authenticationApi = await storefront.getApi('AuthenticationApi');
await authenticationApi.register({
mail: 'email@example.com',
password: 'test123',
name: 'John',
lastname: 'Doe',
phone: '123456789',
street: 'Example Street 8',
flat_number: '20',
postal_code: '12-345',
city: 'Vancouver',
country: 'Canada'
});
});
Authentication API methods reference¶
- selectAuthStatus$
- getAuthStatus
- selectIsAuthorized$
- isAuthorized
- login
- logout
- resetPassword
- setLoginEmail
- getLoginEmail
- selectLoginEmail$
- getAdditionalFieldsForRegistration
- openLoginModal
- closeLoginModal
- openRegisterModal
- closeRegisterModal
- openRemindPasswordModal
- closeRemindPasswordModal