Tried to add MirageJS but failed
This commit is contained in:
parent
6d83c18036
commit
548dd0d022
8 changed files with 681 additions and 373 deletions
|
|
@ -7,7 +7,9 @@
|
|||
"build": "astro build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/renderer-svelte": "^0.1.1",
|
||||
"astro": "0.19.0-next.2",
|
||||
"@astrojs/renderer-svelte": "^0.1.1"
|
||||
"miragejs": "^0.1.41",
|
||||
"typescript": "^4.4.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19
web/src/components/MirageTest.svelte
Normal file
19
web/src/components/MirageTest.svelte
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script lang="ts">
|
||||
|
||||
console.log("sup");
|
||||
let movies = [];
|
||||
|
||||
fetch("/api/movies").then(res => res.json()).then(res => {
|
||||
movies = res;
|
||||
console.log(movies);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
{#each movies as { id, name, year }, i}
|
||||
<li><a target="_blank" href="https://www.youtube.com/watch?v={id}">
|
||||
{i + 1}: {name} - {year}
|
||||
</a></li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<script>
|
||||
<script lang="ts">
|
||||
let count = 0;
|
||||
|
||||
function add() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
---
|
||||
---
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<h1>huh</h1>
|
||||
<p>lol</p>
|
||||
<MirageTest />
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,24 @@
|
|||
---
|
||||
import { createServer } from "miragejs"
|
||||
import MirageTest from "../components/MirageTest"
|
||||
|
||||
createServer({
|
||||
routes() {
|
||||
this.namespace = "api"
|
||||
|
||||
this.get("/movies", () => {
|
||||
return {
|
||||
movies: [
|
||||
{ id: 1, name: "Inception", year: 2010 },
|
||||
{ id: 2, name: "Interstellar", year: 2014 },
|
||||
{ id: 3, name: "Dunkirk", year: 2017 },
|
||||
],
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
---
|
||||
|
||||
<html>
|
||||
<body>
|
||||
|
||||
|
|
@ -7,6 +28,8 @@
|
|||
<li class="nav-bar-item"><a href="/microblog">Microblog</a></li>
|
||||
<li class="nav-bar-item"><a href="/devlogs">Devlogs</a></li>
|
||||
</ul>
|
||||
|
||||
<MirageTest client:load />
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
996
web/yarn.lock
996
web/yarn.lock
File diff suppressed because it is too large
Load diff
Reference in a new issue