'How to retrieve cookie from react application

I'm trying to retrieve cookie data and set it as a request header. First of all I've added withCredentials: true for axios call.

const axiosInstance = axios.create({
  headers: {
    "Content-Type": "application/json",
  },
  baseURL: `https://*****************.amazonaws.com/dev/api/v2`,
  withCredentials: true,
});

it works fine and sends cookie data. Request with cookie

But what I want is to parse cookie data mannually and extract specific field for authHeader.

The thing is, document.cookie retrieves me undefined. In the application tab, I can not see any cookie data stored. Cookie state image

Where is the cookie stored and how can I retrieve cookie data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source