Skip to content

Commit 12c07f1

Browse files
committed
fix types
1 parent f159250 commit 12c07f1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/fetch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,15 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
209209
/* Custom response.text() function to retrieve text from response and get progress values */
210210
let loaded = 0;
211211
const contentLength =
212-
context.response!.headers.get("content-length")!;
213-
const _reader = context.response!.body!.getReader();
212+
context.response?.headers.get("content-length") || "0";
213+
const _reader = context.response?.body?.getReader();
214214
const _decoder = new TextDecoder();
215215
const _chunks: string[] = [];
216216

217217
async function read(): Promise<string> {
218+
if (!_reader) {
219+
return "";
220+
}
218221
const { done, value } = await _reader.read();
219222

220223
if (done) {

0 commit comments

Comments
 (0)