Skip to main content

Introduction

In Headless CMS OneEntry, there are the necessary tools for working with registered users. In this section, you can familiarize yourself with the principles of working with users.

You can store the data necessary for your application to function in a state object. When changing the user, add the necessary data to the state. When the user's data is subsequently retrieved, it will include a state object.

Here’s an example where we add information to the user about how many orders they have made. Add a field "orderCount" with the value to the state object.

const data = {
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Username"
}
],
"notificationData": {
"email": "example@oneentry.cloud",
"phonePush": ["+99999999999"],
"phoneSMS": "+99999999999"
},
"state": {
"orderCount": 1
}
}

const value = await Users.updateUser(data)

When the user's data is retrieved, it will contain information about the number of orders.

const value = await Users.getUser()

console.log(value.state.orderCount) // 1
const config = {
token:'your-app-token',
};

const { Users } = defineOneEntry('your-url', config);