@openstax/ts-utils 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,8 +21,8 @@ declare type RouteClient<R> = {
21
21
  })) => Promise<string>;
22
22
  };
23
23
  interface AcceptStatus<Ro> {
24
- <S extends TResponseStatus<Ro>[]>(...args: S): ApiClientResponse<Extract<Ro, Record<'statusCode', S[number]>>>;
25
- <S extends number[]>(...args: S): ApiClientResponse<any>;
24
+ <S extends TResponseStatus<Ro>[]>(...args: S): Promise<ApiClientResponse<Extract<Ro, Record<'statusCode', S[number]>>>>;
25
+ <S extends number[]>(...args: S): Promise<ApiClientResponse<any>>;
26
26
  }
27
27
  declare type UnsafeApiClientResponse<Ro> = {
28
28
  headers: Headers;
@@ -73,9 +73,9 @@ const makeRouteClient = (initializer, config, route, authProvider) => {
73
73
  }
74
74
  return {
75
75
  status: response.status,
76
- acceptStatus: (...status) => {
76
+ acceptStatus: async (...status) => {
77
77
  if (!status.includes(response.status)) {
78
- throw new Error(`unexpected HTTP ${response.status} response from api`);
78
+ throw new Error(`unexpected HTTP ${response.status} response from api: ${await response.text()}`);
79
79
  }
80
80
  return { status: response.status, headers: response.headers, load: (0, exports.loadResponse)(response) };
81
81
  },