(logoutParams: {
apiClient: SelfManagedApiClient;
})
| 79 | } |
| 80 | |
| 81 | export async function logout(logoutParams: { |
| 82 | apiClient: SelfManagedApiClient; |
| 83 | }) { |
| 84 | const { authApiBasePath } = logoutParams.apiClient; |
| 85 | |
| 86 | const response = await fetch(`${authApiBasePath}/api/logout`, { |
| 87 | method: "POST", |
| 88 | headers: { |
| 89 | "Content-Type": "application/json", |
| 90 | }, |
| 91 | }); |
| 92 | |
| 93 | const responseText = await response.text(); |
| 94 | |
| 95 | const isFetchFailure = !response.ok; |
| 96 | if (isFetchFailure) { |
| 97 | throw new Error(responseText, { |
| 98 | cause: { status: response.status }, |
| 99 | }); |
| 100 | } |
| 101 | return responseText; |
| 102 | } |
| 103 | |
| 104 | export async function logoutAndRedirect(logoutParams: { |
| 105 | apiClient: SelfManagedApiClient; |
no test coverage detected