Skip to content

Commit

Permalink
fix: lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz committed Jun 17, 2023
1 parent bf6cc62 commit b420ef6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/js-runtime/src/runtime/http/fetch.ts
Expand Up @@ -5,7 +5,7 @@
const headers = new Headers(init?.headers);
let body: string | undefined;

const isInputRequest = input instanceof Request
const isInputRequest = input instanceof Request;

if (init?.body || (isInputRequest && (input as Request).body)) {
const paramBody = init?.body || (input as Request).body;
Expand All @@ -15,24 +15,17 @@
} else if (paramBody instanceof ReadableStream) {
body = '';

const reader = paramBody.getReader();

while (true) {
const { done, value } = await reader.read();

if (done) {
break;
}

body += globalThis.__lagon__.TEXT_DECODER.decode(value);
// @ts-expect-error iterate over the stream
for await (const chunk of paramBody) {
body += globalThis.__lagon__.TEXT_DECODER.decode(chunk);
}
} else {
if (typeof paramBody !== 'string') {
// TODO: Support other body types
throw new Error('Body must be a string or an iterable');
}

body = paramBody
body = paramBody;
}
}

Expand Down

0 comments on commit b420ef6

Please sign in to comment.