-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
<script> | ||
export let containers = []; | ||
function showContainers() { | ||
containers = [ | ||
{ id: 1, name: 'Container 1' }, | ||
{ id: 2, name: 'Container 2' }, | ||
] ; | ||
} | ||
</script> | ||
|
||
|
||
<h1>Welcome to SvelteKit</h1> | ||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> | ||
|
||
<button on:click="{showContainers}">Show Containers</button> | ||
|
||
{#each containers as container} | ||
<div> | ||
<span class="id">{container.id}</span> | ||
<span class="name">{container.name}</span></div> | ||
{/each} | ||
|
||
<a href="/fromapi">Fetch from API</a> | ||
|
||
<style> | ||
.id { | ||
margin-right: 10px; | ||
font-weight: bold; | ||
} | ||
.name { | ||
color: #999; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export async function load({ fetch }) { | ||
const res = await fetch(`http://localhost:3000/containers`); | ||
const as_obj = await res.json(); | ||
//console.log({as_obj}); | ||
return as_obj; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script> | ||
export let data; | ||
//console.log({data}); | ||
</script> | ||
|
||
<h1>Fetched from API</h1> | ||
|
||
{#each data.containers as container} | ||
<div> | ||
<span class="id">{container.id}</span> | ||
<span class="name">{container.nameOfShip}</span> | ||
</div> | ||
{/each} | ||
|
||
<style> | ||
.id { | ||
margin-right: 10px; | ||
font-weight: bold; | ||
} | ||
.name { | ||
color: #999; | ||
} | ||
</style> |