fix fetchData to start off as loading

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-17 13:24:09 +02:00
parent 6f53922ad3
commit ab24ecc406
1 changed files with 1 additions and 1 deletions

View File

@ -5,7 +5,7 @@ export default function (url) {
const store = writable({ status: "LOADING", data: {}, error: {} }) const store = writable({ status: "LOADING", data: {}, error: {} })
async function get() { async function get() {
store.update(u => ({ ...u, status: "SUCCESS" })) store.update(u => ({ ...u, status: "LOADING" }))
try { try {
const response = await api.get(url) const response = await api.get(url)
store.set({ data: await response.json(), status: "SUCCESS" }) store.set({ data: await response.json(), status: "SUCCESS" })