fix fetchData to start off as loading
This commit is contained in:
parent
6f53922ad3
commit
ab24ecc406
|
@ -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" })
|
||||||
|
|
Loading…
Reference in New Issue