Retrieving information from a JSON source to populate a data table

Hello fellow developers... I'm currently facing an issue while trying to dynamically populate a data table with information fetched through a fetch request and stored in a Vuex instance variable. Here is the relevant code snippet:

<script>
import { mapActions, mapGetters } from "vuex";
export default {
  name: "Games",
  data() {
    return {
      search: "",
      headers:[
             {text:'Game#', value:'Game#'},
             {text:'Players in Game',value:'Players inGame'},
             {text:'Permissions',value:'Permissions'},
             {text:'Results',value:'Results'},

      ],

    };
  },
  components: {
  },
  props: ["gameid"],
  methods: {
    ...mapActions(["fetchingJsonEvents", "joinToGame","logOut", "createGame"]),

  },
  computed: {
    ...mapGetters(["getGamesAll", "getUserLogged"]),
    getGamesAll(){
       return this.$store.getters.getGamesAll.games-------->here is where the json is stored
    }
  },
  created() {
    this.fetchingJsonEvents();
  }
};
</script>

and my HTML implementation utilizing the computed property:

<v-data-table :search="search" :headers="headers" v-bind:items="getGamesAll">
    <template>
          <tbody>
            <tr v-for="(general, index) in getGamesAll.games" v-bind:key="index">
              <td>Game {{general.id}}:</td>

              <td>xxxxxxxx</td>
              <td>xxxxxxxx</td>
          </tbody>
     </template>
 </v-data-table>

However, the table does not display any results as expected. It was functioning correctly when using a v-simple-table but encountered issues upon switching to this method. Any insights or advice on how to resolve this issue would be greatly appreciated. Thanks in advance!

Answer №1

There is no need for this additional code:

getGamesAll(){
 return this.$store.getters.getGamesAll.games
}

since you already have access to it using mapGetters:

...mapGetters(["getGamesAll", "getUserLogged"]),

If your getter getGamesAll contains the necessary data, then this should suffice:

<tr v-for="(general, index) in getGamesAll.games" v-bind:key="index">

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

Heroku-hosted application experiencing issues with loading website content

I have been working on a nodejs application that serves a web page using express and also functions as a discord bot. The app runs smoothly on localhost with both the web page and discord functionalities working correctly. However, when I deploy it to Hero ...

Tips for retrieving return values from AJAX URL content

As I am writing some code to send data from one page to another through the ajax URL, I encountered an issue where the retrieved values on the previous page are showing as null. The first page code looks like this: <script> function myFunction() { ...

Is there a way to deactivate the onClick event when the dropdown placeholder is chosen?

I have experimented with different methods to prevent the onClick event when selecting either placeholder, but I have not been successful. Here is my current code: <div class="choosesign"> <div class="zodiacs"> < ...

Issue - Following error occurred in the file connection.js located in node_modules/mysql2 library: Module not found: Unable to locate 'tls' module

I've encountered an error in our Next JS applications where tls is not found. I have tried several troubleshooting steps including: 1. Updating Node modules 2. Using both mysql and mysql2 3. Running npm cache clean --force 4. Removing node_modules di ...

What steps can be taken to resolve the mouse-pointer problem?

Currently, I am utilizing PHP, jQuery, JavaScript, and other tools for my website development. I have a new requirement for a script in jQuery/JavaScript that can trigger an alert when the user's mouse-pointer moves away from the tab where my website ...

When the VueJS element is rendered on Chrome addon, it suddenly vanishes

I have been using a developer mode addon successfully in Chrome for quite some time. Now, I want to add a button to my Vue-powered page. Here's the code snippet: let isletCtl = document.createElement('div') isletCtl.id ...

Maximizing HTML5 Game Performance through requestAnimationFrame Refresh Rate

I am currently working on a HTML5 Canvas and JavaScript game. Initially, the frames per second (fps) are decent, but as the game progresses, the fps starts decreasing. It usually starts at around 45 fps and drops to only 5 fps. Here is my current game loo ...

Bootstrap Dropdown Functionality Malfunctioning

Here is a simple piece of HTML code that I have created: <!doctype html> <html> <head> <meta charset="utf-8"> <title>.:Home Page:. The Indian Sentinel</title> <link rel="stylesheet" href=" ...

What could be causing me to not receive the prepackaged error messages from Angular in my WebStorm 8?

Having some trouble here... my angular errors are always so cryptic, like this: I usually manage to figure out the issue on my own, but I'm really hoping someone can offer guidance on how to get those nice error messages that angular supposedly displ ...

Python function that involves repeatedly calling itself for solving a problem

My attempt to process JSON data from an API using Python has hit a roadblock. The results are divided into groups of 100, with a NextPageLink entry in the JSON pointing to the next page. I have created a class with a parser that is supposed to call itself ...

JavaScript Button with the Ability to Input Text in a TextArea?

For instance, imagine a scenario where you click on a button and it then displays various options for you to select from. Whatever option you pick will be automatically inserted into the text area. ...

Get connected to your favorite music on iTunes without the hassle of opening a new window by simply clicking on the

Is there a way to call a link to iTunes (itms://...) without opening a new window? I've tried using window.open but that just opens a new window. Also, $.get('itms://...'); doesn't seem to work for me. Are there any other options avail ...

choose checkbox option in python

Suppose you have an XML document structured as follows: <!-- Location --> <w:t>Location:</w:t> <w:t>Home:</w:t> <w:t>Extension:</w:t> <w:t>Hajvali –Prishtina</w:t> <w:t>Street. "Martyrs of Goll ...

What is the best way to pass props down to grandchildren components in React?

I'm trying to pass some props from a layout to its children. The issue is, it works fine when the child component is directly nested inside the layout, but it doesn't work when the child component is wrapped in another element like a div. Exampl ...

Adding the location of the onClick event to the hook - a step-by-step guide

Here is the code I am working with: import { MapContainer, TileLayer } from "react-leaflet"; import React, { useState } from 'react'; export default function App() { const [positionLat, setPositionLat] = useState(null); ...

Where is the location of the directory on the hard drive that was created using the getDirectory() method in HTML5?

I have been working on creating, deleting, and reading directories but I am unsure of where they are located on the hard drive. fs.root.getDirectory('something', {create: true}, function(dirEntry) { alert('Congratulations! You have succes ...

How can JavaScript determine if this is a legitimate JS class?

I'm currently in the process of converting a React.js project to a next.js project. In my project, there's a file named udf-compatible-datafeed.js. import * as tslib_1 from "tslib"; import { UDFCompatibleDatafeedBase } from "./udf-compatibl ...

When using jQuery's .each method, only the final JavaScript object element is added to the divs

I have a unique set of dynamically-created divs, each containing a Title. When a div is clicked, a modal opens (which is cleared upon click), and the Title is displayed again in the modal. My goal is to add the category descriptions into these modals, but ...

Customize Cell Styling with Bootstrap Full Calendar CSS

I am attempting to implement a Bootstrap calendar feature where cells are colored green if the timestamp is greater than today's date. This can be achieved by: $checkTime > $today cell.css = green background I came across this code snippet on St ...

An issue occurred in the callback function for the watcher "get_settings": "A TypeError was raised because the property 'general' cannot be read

I'm really struggling with handling this error in Vue, especially since I'm new to it. Here's what's happening: I fetch data from the server using a vuex store action. In my component, I access that data using a getter in a computed pro ...