Necesito hacer una llamada api para obtener recomendaciones para un usuario. Esta es mi url api: http://URL/../../patients/ USER ID /recommendations
Mi identificación de usuario está guardada en mi tienda vuex en el archivo "patient.module.js:
state: { id: null, email: null, password: null, location: [], specialty: [], attribute: [], language: [], gender: [], editUser: false, }, getters: { getUserId(state) { return state.id; }, }, La estructura de mi tienda se ve así: 
En mi RecommendationView, trato de mostrar la respuesta json de mi llamada api. Aquí escribí el método para hacer la llamada a la API.
methods: { getRecommendations() { this.id = this.$store.getters.getUserId; return http .get(`/patients/${id}/recommendations`) .then((response) => { this.recommendation = response.data; console.log(response); }) .catch((error) => { console.log( "Ein Fehler beim User ist aufgetreten: " + error.response ); }); }, },Desafortunadamente, recibo este error: id' no está definido. ¿Cómo puedo obtener la identificación del paciente de la tienda y enviarla con mi solicitud? ¡Gracias de antemano!
Puede usar mapState en computado así.
<script> import {mapState} from "vuex"; export default { computed: { ...mapState({ user: state => state.patient }) }, data() {}, methods: { getRecommendations() { this.id = this.user.id; return http .get(`/patients/${id}/recommendations`) .then((response) => { this.recommendation = response.data; console.log(response); }) .catch((error) => { console.log( "Ein Fehler beim User ist aufgetreten: " + error.response ); }); }, } } </script>