Skip to content

Commit cb6ad18

Browse files
committed
API handler for logout
1 parent 16a7e57 commit cb6ad18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

site/api.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ export const login = async (email: string, password: string): Promise<LoginRespo
1414
}),
1515
})
1616

17+
return await readOrThrowResponse(response)
18+
}
19+
20+
export const logout = async (): Promise<void> => {
21+
const response = await fetch("/api/v2/logout", {
22+
method: "POST",
23+
})
24+
25+
return await readOrThrowResponse(response)
26+
}
27+
28+
const readOrThrowResponse = async (response: Response): Promise<any> => {
1729
const body = await response.json()
1830
if (!response.ok) {
1931
throw new Error(body.message)

0 commit comments

Comments
 (0)