💾 store - added localstorage persistence

ref #1
This commit is contained in:
Philipp Dormann 2021-03-15 14:13:19 +01:00
parent df3621d086
commit c2f9da6e92
2 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@
href="https://docs.lauf-fuer-kaya.de/">See our configuration guide.</a></p> href="https://docs.lauf-fuer-kaya.de/">See our configuration guide.</a></p>
<form class="flex flex-col pt-3 md:pt-8" onsubmit="event.preventDefault();" on:submit={()=> <form class="flex flex-col pt-3 md:pt-8" onsubmit="event.preventDefault();" on:submit={()=>
{ {
// TODO: validate token with backend api
console.log(token); console.log(token);
apikey.set(token) apikey.set(token)
}}> }}>

View File

@ -1,3 +1,7 @@
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
export const apikey = writable(''); const stored_apikey = localStorage.getItem('apikey');
export const apikey = writable(stored_apikey);
apikey.subscribe((value) => {
localStorage.setItem('apikey', value);
});