Try to support endpoints which conditionally return 204s
This commit is contained in:
parent
d0ebb6a647
commit
eb0a475242
|
@ -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
|
||||
|
|
|
@ -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[],
|
||||
|
|
Loading…
Reference in New Issue