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

Learn how to dynamically modify the text and color of a column value within a <v-data-table> component in Vue.js 2.6.11 and Vuetify 2.2.11 based on a specific condition

In my current project where I am developing a web application using ASP.NET CORE for the backend and vue.js for the frontend, I encountered an issue with Vuetify's CRUD Datatable UI Component in a page named "Category". The problem arises when trying ...

Posts created in Express using the node-postgres module are not being retrieved by queries in async routes

Running a basic query from an express route seems to be causing some issues for me: var router = require('express-promise-router')() const { Pool } = require('pg') const pool = new Pool({ user: 'user', password: 'pa ...

Unable to modify background color in base website

While working on my project with Next.js, I encountered an issue where creating a button to change the color only affected the base web components' color and not the background color. _app.tsx import '../styles/globals.css'; import type { Ap ...

Cloning a checkbox using Jquery

I am working on a search page that utilizes checkboxes to display results. After the user selects certain options and triggers a reload of the page, I want to provide an easy way for them to remove their selections by displaying them at the top of the page ...

JSON object fails to iterate with ng-repeat

It must be the scorching temperature... Having a json object that I'm eager to loop through using ng-repeat, it should be straightforward, but alas! it's just not cooperating. Here's the HTML snippet: <a data-ng-repeat="x in template.m ...

React Material-UI TextField with Throttling

After exploring React Material UI, I am interested in implementing a TextField component that offers both debouncing and controlled functionality. When we refer to "controlled," we mean that the value persistence is managed externally, with the component a ...

Is there a way to trigger a function upon the loading of a template in Angular 2?

I'm a newcomer to angular2 and I need to trigger a function when a template loads or initializes. I have experience with achieving this in angular1.x, but I'm struggling to figure out how to do it in angular-2. Here's how I approached it in ...

Develop a distinctive JavaScript solution that enables an image to appear in fullscreen upon loading the page, and then smoothly fade away after precisely

I have been trying to incorporate a feature on my Shopify frontage website where our logo appears fullscreen and then fades away or disappears after a few seconds, allowing people to access the rest of the website. However, I am facing difficulty in making ...

Issues with retrieving information between AJAX and PHP (and vice versa)

I have a script that sends the value of a text input from an HTML form to emailform.php. This PHP file then adds the data to a .txt file. The issue I'm facing is setting the value of $email in the PHP file to match that of the HTML input field. Curren ...

Is there a new update to Google Maps API?

After successfully building a map component for a web application using google maps, open layers, and the dojo toolkit, it suddenly stopped loading earlier this morning. Even though there are no JavaScript errors and open layers and Google still initialize ...

Expanding a JSON data structure into a list of items

In my Angular service script, I am fetching customer data from a MongoDB database using Django: getConsumersMongodb(): Observable<any> { return this.httpClient.get(`${this.baseMongodbApiUrl}`); } The returned dictionary looks like this: { &q ...

Managing loading and changing events using Angular, jQuery, and Web API

I am populating a dropdown select using ng-repeat. <select onchange="ChangeMonth()" id="month"> <option ng-repeat="(key,val) in Months" ng-selected="val==ActiveMonth" value="{{key}}"> {{val}} ...

Selection determines the value of two fields

This form has predefined values that are used to create a link, but the issue is that these values vary depending on the location. Can you assist me with this problem? <input type="radio" id="iconapp1" name="department" value="1250"/><label for ...

Displaying random characters in place of Angular 6 font awesome icons

Recently, I started a new project with the angular cli and incorporated font-awesome 4.7.0. After that, I included it as a dependency in my angular.json file. "styles": [ "./node_modules/font-awesome/css/font-awesome.min.css", "./node ...

The "users" property or method has not been defined in Vue.js applications

During the development of my Vue.js shopping cart, I encountered an issue where I wanted to display the username in a label after the user provided correct information. However, I received the following error in Google Chrome: vue.js:634 [Vue warn]: Prope ...

Requiring addresses for Google Maps in order to display directions

To display the directions between two addresses based on the chosen transportation mode, I need to pass the addresses to the code in page 2. After the user selects two cities from a Dropdown box on page 1, they will be sent to the code to show their locati ...

An effective method for sorting a dictionary by its values and converting it into a string

I currently have a dictionary consisting of string keys paired with integer values. for word in coocc[query]: resp[word]=coocc[query][word] {"share": 1, "pizza": 3, "eating": 1,...} To achieve the desired outcome, I am aiming to sort by value and ...

The following error occurred while running the command "php artisan ui vue get": ErrorException - Unable to open stream: File

Trying to set up VueJS for my Laravel project, but encountered an error when running php artisan ui vue: Can someone please advise on how to resolve this issue? Thank you. ErrorException > copy(D:\Code\Hung's Friend\management&bso ...

having trouble with my lambda function reading the basic json object

I recently joined Lambda and have been attempting to create a simple JSON object. However, I keep encountering an error that says "parsing error, unexpected token." Here is my code, which I have verified to be valid JSON: { "metadata": { ...

Disable setTimeout in Node.js triggered by an event

I am facing a dilemma with my code that constantly polls a service and I am looking for a way to efficiently cancel the interval using `clearTimeout` through events. The timeouts essentially act as intervals by calling setTimeout again within the function. ...