Ran linter
parent
13d0d08183
commit
1f52afdfe2
|
@ -1,15 +1,15 @@
|
|||
const API_PREFIX = "/api/v1"
|
||||
const API_PREFIX = '/api/v1'
|
||||
|
||||
export class RbApi {
|
||||
async get_json(path) {
|
||||
async get_json (path) {
|
||||
const url = `${API_PREFIX}${path}`
|
||||
let res = await fetch(url)
|
||||
const res = await fetch(url)
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
async sections() {
|
||||
let res = await this.get_json("/sections")
|
||||
async sections () {
|
||||
const res = await this.get_json('/sections')
|
||||
|
||||
return res["sections"]
|
||||
return res.sections
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ import { ref } from 'vue'
|
|||
import { RbApi } from '../api/v1'
|
||||
import { Section } from '../models'
|
||||
|
||||
let sections = ref([])
|
||||
const sections = ref([])
|
||||
|
||||
let api = new RbApi()
|
||||
const api = new RbApi()
|
||||
await api.sections().then(res => {
|
||||
sections.value = res
|
||||
})
|
||||
|
@ -14,9 +14,9 @@ await api.sections().then(res => {
|
|||
|
||||
<template>
|
||||
<div>
|
||||
<p>yeet</p>
|
||||
<p>yeet</p>
|
||||
<ul>
|
||||
<li v-for='section in sections'>
|
||||
<li v-for="section in sections">
|
||||
{{ section }}
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -29,21 +29,21 @@ export const sections = [
|
|||
is_private: false,
|
||||
is_archived: false
|
||||
}
|
||||
];
|
||||
]
|
||||
|
||||
export const posts = [
|
||||
{
|
||||
id: 'af08bbcd-f6eb-446e-b355-13e0a0ef008e',
|
||||
section_id: sections[0]['id'],
|
||||
section_id: sections[0].id,
|
||||
is_private: false,
|
||||
is_archived: false
|
||||
}
|
||||
];
|
||||
]
|
||||
|
||||
export const versions = [
|
||||
{
|
||||
id: '8c5bc2f9-e52f-4e19-bd76-119cc42ff863',
|
||||
post_id: posts[0]['id'],
|
||||
post_id: posts[0].id,
|
||||
title: 'This Is A Title',
|
||||
publish_date: '2021-12-28',
|
||||
content: 'Hello. This is some content!',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createServer, Model } from 'miragejs';
|
||||
import { sections, posts, versions } from './models';
|
||||
import { createServer, Model } from 'miragejs'
|
||||
import { sections, posts, versions } from './models'
|
||||
|
||||
export function makeServer ({ environment = 'development' } = {}) {
|
||||
const server = createServer({
|
||||
|
@ -12,27 +12,26 @@ export function makeServer ({ environment = 'development' } = {}) {
|
|||
},
|
||||
|
||||
seeds (server) {
|
||||
sections.forEach(s => server.create('section', s));
|
||||
posts.forEach(s => server.create('post', s));
|
||||
versions.forEach(s => server.create('version', s));
|
||||
|
||||
sections.forEach(s => server.create('section', s))
|
||||
posts.forEach(s => server.create('post', s))
|
||||
versions.forEach(s => server.create('version', s))
|
||||
},
|
||||
|
||||
routes () {
|
||||
this.namespace = 'api/v1';
|
||||
this.namespace = 'api/v1'
|
||||
|
||||
// Offsets & limits don't need to be implemented here, as the data set isn't large enough to require this yet
|
||||
this.get('/sections', (schema) => {
|
||||
return schema.sections.all();
|
||||
return schema.sections.all()
|
||||
})
|
||||
this.get('/posts', (schema) => {
|
||||
return schema.posts.all();
|
||||
return schema.posts.all()
|
||||
})
|
||||
this.get('/versions', (schema) => {
|
||||
return schema.versions.all();
|
||||
return schema.versions.all()
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
return server;
|
||||
return server
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue