How can I correct the error in accessing state data with a getter and displaying the outcome in a component?

I am relatively new to vuejs 3 and vuex 4. I'm currently attempting to create a simple getter, but when it didn't work as expected, I resorted to using console.log to check the output. The result that appeared in the console was: ComputedRefImpl {dep: undefined, _dirty: true, __v_isRef: true, effect: ReactiveEffect, _setter: ƒ, …}... I believe I need to implement ref in the computed function used to fetch data from the store getter, but I am unsure about how to proceed in this scenario.

state: {
  
  title:'hello'
},

getters: {

title: state => state.title

},
<template>

  {{title}}

</template>



<script>

import {computed, ref} from 'vue'
import {useStore} from 'vuex'
export default {
  name: 'Lista',

  setup(){
    const store = useStore();

    const nuevaSerie = ref("");
    let title = ref("");

    /*  const borrar_todo = async (index) =>{
        store.dispatch ('lista/borrar_todo',{ 
          index
        })
      }
            
      const nueva_serie = async (nombre) =>{
        store.dispatch ('lista/nueva_serie',{
          nombre
        }) 
      }

      const colores = async (index) =>{
        await new Promise( (aceptar)=>{   
                setTimeout( ()=>{
                    aceptar()
                },100)
            })
        store.dispatch ('lista/colores', index)
      }*/



       title = computed(() => store.getters.title)
        console.log(title)

      
    let series = store.state.lista.series

    return { series, nuevaSerie, nueva_serie, borrar_todo, colores, title}
  }   
}
</script>

Answer №1

After some thorough investigation, I managed to pinpoint the source of the error. It turns out that my approach to calling the store getter was incorrect all along. Just to clarify, 'lista' is actually the name of the module.

<script>

let title = computed(() => $store.getters["lista/title"])

</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The pagination component in React with Material-ui functions properly on a local environment, but encounters issues when deployed

Looking for some assistance with a persistent issue I've run into. Can anyone lend a hand? [x] The problem persists in the latest release. [x] After checking the repository's issues, I'm confident this is not a duplicate. Current Behavior ...

Removing API request in React.js

My approach: deleteSample = () => { this.sampleService .deleteCall(this.props.id) .then((response) => { window.location.reload(false); }) .catch((error) => { console.log ...

Encountering an issue when trying to retrieve the "createdAt" property in Cloud Code using the Parse Framework

I am working with Cloude Code to develop a more complex query, but I am having trouble accessing the automatically created "createdAt" property by Parse. Here is my code: Parse.Cloud.define("get_time", function(request, response) { var query = new Par ...

Expanding Perspective in React Native

Having trouble with implementing a camera feature that isn't scaling correctly. The issue seems to be related to the styling of the container View, as when the camera is rendered independently it works fine. The goal is for the camera to activate when ...

How can Node.js improve callback functions and integrate nodemailer for optimal performance?

I'm currently working on a new feature that involves sending a post request to download HTML pages from specific URLs, zip them, and then email the zipped file to a designated email address. The endpoint for this route looks like http://localhost:3000 ...

Creating a progress bar feature using local storage in JavaScript

Is there a way to retain the progress of the countdown timer with a progress bar on page reload? Here is an example of what I am trying to achieve: https://codepen.io/Rudchyk/pen/qNOEGj <div id="progressBar"> <div class=& ...

The Art of Validating Forms in Vue.js

Currently I am in the process of developing a form with validation using Vue, however, I've run into some errors that are showing up as not defined even though they are currently defined. HTML <form class="add-comment custom-form" @submit="checkF ...

Sorting prices in descending order using Expedia API

Is there a way to arrange prices in descending order using the response.hotelList[i].lowRate? The provided code is as follows: success: function (response) { var bil = 1; var hotel_size = response.hotelList.length; $('#listD ...

Posts that are repeated when making an AJAX call in WordPress

I have been experimenting with implementing a 'load more' button feature in my WordPress site. The concept is simple - users click the button, and additional posts are loaded using AJAX without the need for page reload or pagination. Following a ...

Cascading MVC 2 Dropdown menus

I am trying to bind a dropdown based on the change of another dropdown, but I keep getting an "Undefined" error. Here is my code snippet: <select id="BreakOutValue" class="input1_drop" onchange="onChange()" ></select> <%:Html.DropDownList( ...

What could be causing the sporadic functionality of my jQuery image resizing code?

Seeking help for an issue I am facing with my jQuery code. I have been trying to scale a group of images proportionally within an image carousel using jCarousel Lite plugin. However, the resizing code seems to work randomly and I can't figure out why. ...

How can I take photos in bulk when I open the camera on Ionic 3?

Is there a way to capture multiple images at once using the camera? Currently, I am only able to capture one image when the user clicks. However, I would like to capture four images when the user clicks the success button. let options: CaptureImageOption ...

Difficulty with Launching a Modal using Jquery (jquery-3.6.1.min.js) in Conjunction with Bootstrap 5.2.3

I'm having trouble getting a modal to open with jQuery after upgrading to newer versions of JQuery and Bootstrap. Any suggestions? JQUERY CODE - $("#exampleModal").modal(); JSP CODE - I followed the code from the Bootstrap website : ...

Issue encountered: NPM error, unable to find solution for resolving dependency and addressing conflicting peer dependency

I am facing difficulties deploying my project on netlify due to NPM errors. Below are the dependencies: "dependencies": { "@angular/animations": "~15.1.1", ... (list of dependencies continues) ...

What is the best way to create a self-referencing <div> in HTML?

After extensive research, I turn to seeking advice and guidance on Stack Exchange. I have a seemingly straightforward goal in mind. I want to create a <div> id/class that will automatically generate a link to itself using scripting of some sort. Be ...

What is the method for sending arguments to material avatar using require?

import Avatar from '@material-ui/core/Avatar'; Here is an example of working code: <Avatar alt="user 4" src={require('Assets/img/user-1.jpg')} className="size-80 rounded-circle border-info rct-notify" /> However, I encountered ...

Combining JSON objects to form a new object within a JSON object using JavaScript

Here is the JSON data that I have: {"rows":[ {"shiftId":1,"shift":"Morning","item":"Tea","value":20}, {"shiftId":1,"shift":"Morning","item":"Coffee","value":30}, {"shiftId":2,"shift":"Evening","item":"Tea","value":40}, {"shiftId":2,"shift" ...

Tips for displaying the date in 13-digit Unix Timestamp format using JSpreadSheet

I am faced with a challenge involving data that is stored in Unix Timestamp format, which I need to display as a readable date (e.g. YYYY/MM/DD) in JSpreadSheet ("jspreadsheet-ce"). Currently, the data appears as a 13-digit number and looks unattractive. ...

Encountering a Next.js Strapi error. TypeError: Fetch request unsuccessful

An error occurred during module build: UnhandledSchemeError: The plugin does not support reading from "node:assert" URIs (Unhandled scheme). Webpack natively supports "data:" and "file:" URIs. You might require an extra plugin to handle "node:" URIs. ...

Launching URLs from JSON data in the system browser - Apache Cordova

I am facing an issue with opening links from a JSON in the system browser on both Android and iOS devices. The link generated by the function appears as: {{item.addressLink}}, instead of bit.ly/xyzxyz Here is what I currently have: <a href="#" ng-cl ...