0

I am using react-cookie in react. What I want is to delete cookies when the web browser is closed. When I receive the response, I saved the cookie with cookie.set.

If I want to delete the cookie when the web browser is closed, I saw an article asking i have to put 0 in expires when i set cookie.set. But when I try to set expires to 0, I get this error.

 types.d.ts(7, 5): The expected type comes from property 'expires' which is declared here on type 'CookieSetOptions'

How sholud i fix my code?

    import {Cookies} from 'react-cookie'
    const cookies = new Cookies()


    const response = await axios.post('myapi', data,
    {withCredentials: true}
    );

    cookie.set('roleCode',response.data.roleCode, {expires :'0'})
user19476497
  • 495
  • 1
  • 10

0 Answers0