Skip to content

Instantly share code, notes, and snippets.

import axios from 'axios'
import { BaseApi } from '@/api/baseApi'
export class AxiosApi extends BaseApi {
constructor() {
super()
}
async fetch(url: string): Promise<any> {
const { data } = await axios.get(`${this.baseUrl}${url}`)
return data
import { BaseApi } from '@/api/baseApi'
import { FetchApi } from '@/api/fetchApi'
import { AxiosApi } from '@/api/axiosApi'
export class Api extends BaseApi {
private provider: any = new AxiosApi()
async fetch(url: string): Promise<any> {
return await this.provider.fetch(url)
}
}
<template>
<div class="todo-list__row">
<span>{{ todo.id }}: </span>
<span :class="{ 'todo-list__row--completed': todo.completed }">{{
todo.title
}}</span>
</div>
</template>
<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'
<template>
<div>
<Header listName="My new todo list" />
<main>
<TodoList>
<TodoRow v-for="todo in todos" :key="todo.id" :todo="todo" />
</TodoList>
</main>
</div>
</template>
<template>
<div>
<Header listName="My new todo list" />
<main>
<TodoList>
<!--<TodoCard-->
<!--v-for="{ id, title, completed } in todos"-->
<!--:key="id"-->
<!--:title="title"-->
<!--:completed="completed"-->
import { BaseApi } from '@/api/baseApi'
import { FetchApi } from '@/api/fetchApi'
import { AxiosApi } from '@/api/axiosApi'
import { IApi } from '@/types'
export class Api extends BaseApi implements IApi {
private provider: any = new AxiosApi()
async fetch(url: string): Promise<any> {
return await this.provider.fetch(url)
}
<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>
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link> |
<router-link to="/contacts">Contacts</router-link>
</div>
<router-view/>
</div>
</template>
<template>
<div>
<h1>This is a home page</h1>
</div>
</template>
<script>
export default {
name: 'Home'
}
<template>
<div>
<h1>This is an about page</h1>
</div>
</template>
<script>
export default {
name: 'About'
}