Try to support endpoints which conditionally return 204s

This commit is contained in:
Andrew Kingston 2024-12-10 16:38:30 +00:00
parent d0ebb6a647
commit eb0a475242
No known key found for this signature in database
2 changed files with 5 additions and 2 deletions

View File

@ -158,7 +158,9 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
if (response.status >= 200 && response.status < 400) {
handleMigrations(response)
try {
if (parseResponse) {
if (response.status === 204) {
return undefined as ResponseT
} else if (parseResponse) {
return await parseResponse(response)
} else {
return (await response.json()) as ResponseT

View File

@ -9,6 +9,7 @@ import {
CreateAdminUserRequest,
CreateAdminUserResponse,
DeleteInviteUsersRequest,
DeleteUserResponse,
InviteUsersRequest,
InviteUsersResponse,
SaveUserResponse,
@ -55,7 +56,7 @@ export interface UserEndpoints {
userId: string,
appId: string
) => Promise<{ message: string }>
getAccountHolder: () => Promise<AccountMetadata | null>
getAccountHolder: () => Promise<AccountMetadata | undefined>
searchUsers: (data: SearchUsersRequest) => Promise<SearchUsersResponse>
createUsers: (
users: User[],