Unable to extract data from object list in Vue.js

Hi, I'm new to coding and trying to implement a function that shows related articles using Java with REST api. However, when I call the API using axios, the data is not being displayed on the view.

I have checked the API and confirmed that it is returning data. Here is my HTML code:

<div class='related-article-list'>
    <div id="list-related-el">
        <related-list></related-list>
    </div>

<template id="related-list">
    <div class="ralated-article-container" v-for="r in relatedLists" :key="r.id">
        <div class="ralated-article-title">
            <a v-bind:href="r.link">{{r.title}}</a>
        </div>
        <div class="user-name">
            <a v-bind:href="r.userLink">{{r.user}}</a>
        </div>
        <div class="view-total">
            <p>{{r.view}}</p>
        </div>
    </div>
</template>

This is my Script code:

<script type="text/javascript">
    $(document).ready(function () {
        var id = ([[${ topicChapter.getId() }]]);
        var listRelated = new Vue({
            el: "#list-related-el",
            components: {
                'related-list': {
                    template: '#related-list',
                    data() {
                        return {
                            url: "api/get-related-article",
                            id: id,
                            relatedLists: [],
                            dataSize: 0
                        };
                    },

                    methods: {
                        getData: function () {
                            axios.get(`${this.url}id=${this.id}`).then(response => {
                                    this.relatedLists = response.data.data;
                            });
                        }

                    },
                    watch: {
                        page: {
                            immediate: true,
                            handler(newVal, oldVal) {
                                this.getData();
                            }
                        }
                    }
                }
            }
        });

    })
</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

jinja2.exceptions.UndefinedError: The variable 'asset' has not been defined

Currently in my project, I am using a Python backend to fetch data from an API and then rendering it through Flask to the Vue.js frontend. However, I have encountered an error titled that is causing some issues. I have double-checked and printed the varia ...

The Selenium test functions correctly in the production environment, however it encounters issues when run

I am facing an issue with my Vue.js application while writing Selenium tests. The test passes when run against the deployed production version of the app, but fails when run against a local version. When running the app locally, it is not from a build, bu ...

Solving the CORS problem between Vue.js and Flask: Troubleshooting XMLHttpRequest Blockade

Description: Currently working on developing a web application utilizing Vue.js for the frontend and Flask for the backend. The initial phase involves creating a simple login page, but encountering CORS (Cross-Origin Resource Sharing) issues when making r ...

Flask static serving causes Vue app to not render

Currently, I am in the process of developing a basic web application utilizing Flask for the backend and Vue for the client side. Here is an overview of my folder structure: . ├── client/ │ ├── dist/ │ │ ├── css/ │ │ ...

An error occurred: gyp ERR! stack - The command `python -c import sys; print "%s.%s.%s" % sys.version_info[:3]` has failed

While attempting to npm install in a Vue project, I encountered an error even after running vue create (name): npm ERR! gyp verb check python checking for Python executable "c:\Python310\python.exe" in the PATH npm ERR! gyp verb `which` ...

Executing a python script on the client side with the help of Vue.js

Because of restricted computation capabilities, I need to execute a python script on the user's browser. Currently, my website utilizes Vue.js for the frontend and Django for the backend. Do you have any suggestions on how I can specifically run thi ...

What is the most efficient method for transferring Flask variables to Vue?

I am currently developing a visualization application using a flask server and vue.js for the front end. Other discussions on this topic explore how to avoid conflicts between vue.js and flask variable syntax, as shown here. In my scenario, I'm inte ...

Django Vue3 encounters access-control-allow-origin restriction

I am currently working on a Django rest-api project that uses Vue on the front-end. Unfortunately, I encountered an error while making requests via Vue: Console output: The following error is displayed: Access to XMLHttpRequest at 'https://api.iyziw ...