V
V
vbNoName2018-08-14 22:39:41
React
vbNoName, 2018-08-14 22:39:41

How to check if a cookie exists before sending a request to axios server?

There is a React application, requests to the server are sent using axios. Axios is configured like this

import axios from 'axios';
    
    export default axios.create({
        baseURL: `${process.env.REACT_APP_URL_API}`,
        withCredentials: true
    })

How can I add a check before every cookie request? Or how to add a server response check in one place, and if the server replies that the user is not authorized, then log him out, and if the server replied that everything is OK, then we send the answer further

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question