I installed js-cookie using `yard add js-cookie and put this line in application.js
require(“js-cookie”)
but when I use this code in my channel:
console.log(Cookies.get(‘current_user_id’))
I get the error Cookies is not defined
I installed js-cookie using `yard add js-cookie and put this line in application.js
require(“js-cookie”)
but when I use this code in my channel:
console.log(Cookies.get(‘current_user_id’))
I get the error Cookies is not defined
After placing <%= javascript_pack_tag ‘js-cookie’, ‘data-turbolinks-track’: ‘reload’ %> in application.html.erb I get the error that it hasn’t been included in manifest.js
I had this issue few days ago. My solution:
terminal:
yarn add js-cookie
app/javascript/packs/application.js
window.Cookies = require("js-cookie")
my original blogpost