This might be a little confusing - I'm trying to retrieve the value of a cookie from inside a js file and to do this im using the js-cookie library over a CDN create from the JS file. However Cookies is undefined when i try to access the library.
I'm wondering what the problem is and what my best option is to do this?
var jQueryScript = document.createElement("script");
jQueryScript.setAttribute(
"src",
"https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"
);
jQueryScript.setAttribute("type", "module");
document.head.appendChild(jQueryScript);
// Cookies.get is not defined.
var cookieval = Cookies.get("shopOrigin");
console.log(cookieval);
Any help would be much appeciated, it is most likely something simple i am missing. Thanks