title: TypeError: Cannot read properties of undefined (reading 'set')
body: <p>While I am trying to develop mern ec site.
  This error has occurred on the sign in page.</p>
  <p>what I have tried</p>
  <p>1 Cookies-&gt;Cookie, set-&gt;Set</p>
  <p>2 res.refresh_token-&gt;'res.refresh_token'</p>
  <p>3 downgrade js-cookies version from 3 to 2.2.1</p>
  <p><a href="https://i.stack.imgur.com/3uoHz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3uoHz.png" alt="enter image description here" /></a></p>
  <pre><code>Cookies.set('refreshtoken', res.refresh_token, {
        path: 'api/auth/accessToken',
        expires: 7
      })
  </code></pre>
  <p>all code(except html)</p>
  <pre><code>import Head from &quot;next/head&quot;
  import Link from &quot;next/link&quot;
  import { useState, useContext } from &quot;react&quot;
  import { DataContext } from &quot;../store/GlobalState&quot;
  import { postData } from &quot;../utils/fetchData&quot;
  import { Cookies } from 'js-cookie'
  
  const Signin = () =&gt; {
    const initialState = { email: '', password: '' }
    const [userData, setUserData] = useState(initialState)
    const { email, password } = userData
  
    const { state, dispatch } = useContext(DataContext)
  
    const handleChangeInput = e =&gt; {
      const { name, value } = e.target
      setUserData({ ...userData, [name]: value })
      dispatch({ type: 'NOTIFY', payload: {} })
    }
  
    const handleSubmit = async e =&gt; {
      e.preventDefault()
      dispatch({ type: 'NOTIFY', payload: { loading: true } })
      const res = await postData('auth/login', userData)
  
      if (res.err) return dispatch({ type: 'NOTIFY', payload: { error: res.err } })
      dispatch({ type: 'NOTIFY', payload: { success: res.msg } })
  
      dispatch({
        type: 'AUTH', payload: {
          token: res.access_token,
          user: res.user
        }
      })
  
      Cookies.set('refreshtoken', res.refresh_token, {
        path: 'api/auth/accessToken',
        expires: 7
      })
  
      localStorage.setItem('firstLogin', true)
    }
  }
  
  export default Signin
  </code></pre>