I want to get API information and set the data-table. But my code has error. Error messages are below in console.
Property or method "items" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
Please someone advise me?
and also my English is not good so please someone help my question to correctly English.
<template>
<v-app>
<v-data-table dense :headers="headers" :item="items" class="elevation-1"></v-data-table>
</v-app>
</template>
<script lang="ts">
import { Component, Vue } from "nuxt-property-decorator";
import axios from "axios";
@Component
export default class AxiosPractice extends Vue {
items: object[] = [];
headers = [
{ text: "id", value: "postId" },
{ text: "name", value: "name" },
{ text: "email", value: "email" }
];
async mounted() {
const response = await axios.get(
"https://jsonplaceholder.typicode.com/posts/1/comments"
);
this.itmes = response.data.map((comment:any) => ({
postId: comment.postId,
email: comment.email,
name: comment.name
}));
}
}
</script>
awaitwiththen(), it just makes things confusing