forked from antoninpire/rest
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
453d3e9
commit 5ec309a
Showing
1 changed file
with
27 additions
and
3 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 |
---|---|---|
@@ -1,13 +1,37 @@ | ||
<script lang="ts"> | ||
let loading = false; | ||
let url = ''; | ||
let response = ''; | ||
let method: 'GET' | 'POST' = 'GET'; | ||
async function handleClick() { | ||
loading = true; | ||
await fetch('http://localhost:5173/api/seed', { | ||
method: 'POST' | ||
const res = await fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
email: '[email protected]', | ||
password: 'demo' | ||
}), | ||
headers: { | ||
'Content-type': 'application/json' | ||
} | ||
}); | ||
const json = await res.json(); | ||
response = JSON.stringify(json, null, 2); | ||
loading = false; | ||
} | ||
</script> | ||
|
||
<button disabled={loading} on:click={handleClick}>{!loading ? 'Seed' : 'Seeding...'}</button> | ||
<input type="text" bind:value={url} class="bg-black border-white border min-w-[450px]" /> | ||
<select bind:value={method} class="text-white bg-black"> | ||
<option value="GET">GET</option> | ||
<option value="POST">POST</option> | ||
</select> | ||
<button disabled={loading} on:click={handleClick}>{!loading ? 'Send' : 'Sending...'}</button> | ||
<br /> | ||
<pre>{response}</pre> | ||
|
||
<!-- local to local WORKS --> | ||
<!-- cloud to local WORKS --> | ||
<!-- local to cloud WORKS --> | ||
<!-- cloud to cloud ??? --> |