anish2690 / vue-cookie-next

A vue 3 plugin for handling browser cookies with typescript support. Load and save cookies within your Vue 3 application
MIT License
53 stars 6 forks source link

removeCookie doesn't work in composition API #14

Open greendrake opened 2 years ago

greendrake commented 2 years ago

There is no this inside the removeCookie method when using the composition API (it is used to call isCookieAvailable).

JCCorreale commented 5 months ago

for others who may face this issue, here's a (ugly) workaround

import { useCookie } from 'vue-cookie-next'
const { removeCookie, isCookieAvailable } = useCookie()
...
// removeCookie("USER_ID") TypeError: Cannot read properties of undefined (reading 'isCookieAvailable')
removeCookie.bind({ isCookieAvailable: isCookieAvailable})("USER_ID")