Fetch Data By Id Using Axios API

So I have 2 page which connected, page class.vue and detail.vue. I want to show data detail class in detail.vue, so I send the id by params from class.vue using router-link like this :

Show Detail

and in detail.vue, like this:


script:
mounted(){
this.id = this.$route.params.id;
const urlGetClass = process.env.VUE_APP_API+’/api/get-class/’;

axios
.get(urlGetClass + this.$route.params.id)
.then(response => {
    this.detailCls = response.data.data.responsePayload
    console.log("detail", response.data.data.responsePayload);
})

}

why the data doesn’t show, but in url id already exist?

The code provided is currently not properly formatted for this forum. In its current state it’s illegible which makes it hard for people to help you.

Please read the following guide about how to properly format code and then edit your topic accordingly.

Thanks!