When I try to use js-cookie, my javascript file can't seem to track down the Cookies variable from js.cookie-js.js. In my index.html file, I reference the script using this line of code:
<script src="/node_modules/js-cookie/src/js.cookie.js"></script>
In my index.js file, the first time I reference js-cookie, in order to check if any cookies have been established, I call this line of code:
if (!(Cookies.get('user_id'))) {
From there, I always get the following error:
ReferenceError: Cookies is not defined
at Namespace.<anonymous> (/Users/sourabh/sourabhmarathe.github.io/index.js:16:2)
at emitOne (events.js:116:13)
at Namespace.emit (events.js:211:7)
at Namespace.emit (/Users/sourabh/sourabhmarathe.github.io/node_modules/socket.io/lib/namespace.js:213:10)
at /Users/sourabh/sourabhmarathe.github.io/node_modules/socket.io/lib/namespace.js:181:14
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
Probably you're not loading the right library for that, here is the cdn to load before your rules:
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With