Skip to content

Instantly share code, notes, and snippets.

@NovoManu
Created August 19, 2019 12:21
Show Gist options
  • Save NovoManu/c7971036ebc72e3341ede4ec0d82a002 to your computer and use it in GitHub Desktop.
Save NovoManu/c7971036ebc72e3341ede4ec0d82a002 to your computer and use it in GitHub Desktop.
<template>
<div>
<Header listName="My new todo list" />
<main>
<TodoList>
<TodoCard v-for="todo in todos" :key="todo.id" :todo="todo" />
</TodoList>
</main>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { ITodo } from '@/types'
import { Api } from '@/api'
import Header from '@/components/Header.vue'
import TodoList from '@/components/TodoList.vue'
import TodoCard from '@/components/TodoCard.vue'
@Component({
components: { Header, TodoList, TodoCard }
})
export default class Home extends Vue {
todos: ITodo[] = []
async mounted() {
this.todos = await this.fetchTodos()
}
async fetchTodos(): Promise<ITodo[]> {
const api = new Api('todos')
return await api.fetch()
}
}
</script>
<style lang="scss">
.container {
padding: 1.5rem;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment