R
R
real22102018-05-23 08:24:03
React
real2210, 2018-05-23 08:24:03

How to send data to the database after registration. react+redux?

What would be the best way to implement this thing?
And another question is, to store the authorization status in localstorage?
or are there other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-05-23
@real2210

1. Send a registration request to your API
2. In case of successful registration, the backend server puts the user object in the database and sends you a response, for example:
3. Save the necessary data from the answer in the store. You can also write the token to LS or to a cookie.
4. After reloading the page, send a request with a token to the server, to the path, such as /validate. The server checks and if everything is OK, it answers "OK, access is allowed + user data".
With a login, the data is entered, there is a request for /login, for example, and the answer is OK + token + user data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question