Skip to content

Commit 23b5e16

Browse files
committed
Narrow the contract response mode where it is read
1 parent dc4f41b commit 23b5e16

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎apps/sim/lib/api/client/request.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ export async function readContractResponse<C extends AnyApiRouteContract>(
219219
contract: C,
220220
response: Response
221221
): Promise<ContractJsonResponse<C>> {
222+
if (contract.response.mode !== 'json') {
223+
throw new Error(`Contract ${contract.method} ${contract.path} does not declare a JSON response`)
224+
}
225+
222226
const { parsed, raw } = await readResponseBody(response)
223227
if (!response.ok) {
224228
throw new ApiClientError({

0 commit comments

Comments
 (0)