Function
parseResponse
(
response: ResponsePromise,
type: 'json' | 'blob' = 'json',
)
Source from the content-addressed store, hash-verified
| 93 | }); |
| 94 | |
| 95 | export async function parseResponse<T>( |
| 96 | response: ResponsePromise, |
| 97 | type: 'json' | 'blob' = 'json', |
| 98 | ): Promise<T> { |
| 99 | try { |
| 100 | if (type === 'blob') return (await response.blob()) as T; |
| 101 | return await response.json<T>(); |
| 102 | } catch (error) { |
| 103 | Sentry.captureException(error); |
| 104 | throw error; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | async function discardResponse(response: ResponsePromise): Promise<void> { |
| 109 | try { |
Tested by
no test coverage detected