Login API request implemented
This commit is contained in:
parent
bcd03eeeda
commit
985b94b109
2 changed files with 36 additions and 7 deletions
|
|
@ -6,4 +6,8 @@
|
||||||
|
|
||||||
## Run the docker container
|
## Run the docker container
|
||||||
|
|
||||||
``docker run --name svelte -dp 5173:5173 svelte``
|
``docker run --name svelte -dp 5173:5173 svelte``
|
||||||
|
|
||||||
|
## Mastercommand for rebuild run etc.
|
||||||
|
|
||||||
|
``docker build -t svelte .;docker stop svelte;docker rm svelte; docker run --name svelte -dp 5173:5173 svelte``
|
||||||
|
|
@ -1,5 +1,30 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
|
let user: string;
|
||||||
|
let password: string;
|
||||||
|
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
console.log(user, password)
|
||||||
|
const endpoint = "http://localhost:1337/api/auth/local";
|
||||||
|
const payload = {
|
||||||
|
identifier: user,
|
||||||
|
password: password
|
||||||
|
};
|
||||||
|
|
||||||
|
const login = await fetch(endpoint, {
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await login.json();
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -10,16 +35,16 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<main class="form-signin w-100 m-auto">
|
<main class="form-signin w-100 m-auto">
|
||||||
<form>
|
|
||||||
<img class="mb-4" src="/docs/5.2/assets/brand/bootstrap-logo.svg" alt="Logo" width="72" height="57">
|
<img class="mb-4" src="/docs/5.2/assets/brand/bootstrap-logo.svg" alt="Logo" width="72" height="57">
|
||||||
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
|
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
|
||||||
|
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
|
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com" bind:value={user}>
|
||||||
<label for="floatingInput">Email address</label>
|
<label for="floatingInput">Email address</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
|
<input type="password" class="form-control" id="floatingPassword" placeholder="Password" bind:value={password}>
|
||||||
<label for="floatingPassword">Password</label>
|
<label for="floatingPassword">Password</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -28,9 +53,9 @@
|
||||||
<input type="checkbox" value="remember-me"> Remember me
|
<input type="checkbox" value="remember-me"> Remember me
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
|
<button class="w-100 btn btn-lg btn-primary" on:click={handleSubmit}>Sign in</button>
|
||||||
<p class="mt-5 mb-3 text-muted">© 2017–2022</p>
|
<p class="mt-5 mb-3 text-muted">©2022</p>
|
||||||
</form>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue