K
K
keyotor2021-09-12 17:47:29
React
keyotor, 2021-09-12 17:47:29

How to create cookies in react after response from server?

I have an authorization request to the server:

axios
        .post(
          "http://localhost:5000/api/auth/sign-in",
          { ...values },
        )
        .then((res) => {
          const { token } = res.data;
         //здесь мне нужно сохранить куки с токеном который пришел ответом от сервера
        })

after successful authorization, the server sends a token, how can I store this token in a cookie with the httpOnly flag?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-09-12
@Seasle

So the server should return such title.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question