'Uncaught TypeError: Cannot read property ‘get’ of undefined

I’m using vue-cookies in my app, I want to read my cookies by using vue-cookies, when I’m calling the API I have an error

Uncaught TypeError: Cannot read property
Uncaught TypeError: Cannot read properties of undefined (reading 'get'), vue-cookies already installed and defineded in main.js
import axios from "axios";

import Vue from "vue";

const Api = axios.create({

  baseURL: "http://localhost:564404/api/",

});

Api.defaults.headers.common["Content-Type"] = "application/json";

Api.defaults.headers.common["Authorization"] = "Bearer " + Vue.$cookies.get("auth");

export default Api;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source