diff --git a/src/lib/api/apiStore.ts b/src/lib/api/apiStore.ts index ddade439..2120f176 100644 --- a/src/lib/api/apiStore.ts +++ b/src/lib/api/apiStore.ts @@ -32,8 +32,11 @@ export interface Assignment { export async function updateFiles() { const api = getContext('api') as ApiHandler; - const userDocuments = await api.getUserDocuments(); - const userDocumentsJson = await userDocuments.json(); + const response = await api.getUserDocuments(); + if (!response) { + throw new Error('Could not update files due to no response'); + } + const userDocumentsJson = await response.json(); console.log(userDocumentsJson); fileStore.set(userDocumentsJson); @@ -57,18 +60,20 @@ export function updateUserInfo(state: AuthorizerState) { // Explicitly specify the type of the store export const fileStore = writable([]); +export const assignmentStore = writable([]); interface userInfo { name: string; } export const userInfo = writable(); -export const assignmentStore = writable([]); - export async function updateAssignments() { const api = getContext('api') as ApiHandler; const response = await api.getAssignments(); + if (!response) { + throw new Error('Could not update assignments due to no response'); + } const json = await response.json(); assignmentStore.set(json);