getUser
Fetches the authenticated user's data. 🔐 This method requires authorization.
Description
Resolves to an IUserEntity. Pass langCode to get the data in another language; by default the SDK uses the langCode set in defineOneEntry.
.getUser(
);
Parameters schema
Schema
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
Examples
Minimal example
// 1. Sign inawait AuthProvider.("email", { { , , }, { , } ]});
// 2. Fetch the userconst response = await Users.getUser();
Example response
{
"id": 8,
"total": "1",
"identifier": "john@example.com",
"authProviderIdentifier": "email",
"formData": [
{
"marker": "name_reg",
"type": "string",
"value": "John"
},
{
"marker": "phone_reg",
"type": "string",
"value": "+19258382556"
}
],
"formIdentifier": "reg",
"groups": [
1
],
"state": {},
"rating": {},
"moduleFormConfigs": []
}
Response schema
Schema: IUserEntity
id: number
Object ID.
example: 12345
identifier: string
The user's login: an email, phone number or username, depending on the auth provider.
example: "user_12345"
authProviderIdentifier: string
Marker of the authentication provider.
example: "auth_provider_12345"
formData: FormDataType[]
Form fields with their values.
example:
[
{
"marker": "last_name",
"type": "string",
"value": "Username"
}
]
formIdentifier: string
Marker of the form.
example: "form_12345"
total: string
Deprecated, do not rely on it. A service counter that leaks into the response of a single user: always "1", it carries no data about the user. The API reference does not describe it, and the field may disappear from the response.
example: "1"
groups: Array<string | number>
IDs of the user groups the user belongs to.
example:
[
"group_1",
"group_2"
]
state: object
Custom key-value data stored with the user.
example:
{
"orderCount": 1
}
moduleFormConfigs: Array<IFormConfig>
Form configurations of the module associated with the user.
rating: IRating
Rating data: average value, likes and dislikes, and the calculation method.
distance: number
Cosine distance to the query (lower is closer). Present only on items returned by getUsersByVectorSearch().
example: 0.12
Usage examples
A step-by-step walkthrough:
- Update user: fetch the current user before building an edit form, and again after the update.
Try it live
Run this method interactively in the JS SDK sandbox. Connect your Project URL and App Token on first visit, then open:
- Update user: fetch the current user before building an edit form, and again after the update.
- OAuth: load user data after signing in through an OAuth provider.