Skip to content

Commit 60c0ddb

Browse files
author
Sebastien Ringrose
committed
feat: dataURL response bodies
1 parent decda77 commit 60c0ddb

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ export class Store {
3232
const fcn = parseFcnString(nodeStr)
3333
return fcn
3434
})
35-
this.addConstructor("Response", (nodeStr: string) => {
35+
this.addConstructor("Response", async (nodeStr: string) => {
3636
const data = JSON.parse(nodeStr)
3737

3838
const headers = new Headers()
3939
data.headers.forEach((entry: string[]) => headers.set(entry[0], entry[1]))
4040

41-
return new Response(data.body, {
41+
return new Response((await fetch(data.body)).body, {
4242
status: data.status,
4343
statusText: data.statusText,
4444
headers
@@ -81,7 +81,7 @@ export class Store {
8181
const nodeString = await this.shelf.get(nodeId)
8282
if (!nodeString) throw new Error(`No node string found for item with id ${nodeId}`)
8383

84-
const nodeObj = constructor(nodeString)
84+
const nodeObj = await constructor(nodeString)
8585
this.#basket.set(nodeId, nodeObj)
8686

8787
for (const key in nodeObj) {

utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export async function serialize (node: unknown): Promise<string> {
1212
const bodyBlob = await node.blob()
1313
reader.readAsDataURL(bodyBlob)
1414

15-
const bodyDataURL = await new Promise(res => {
15+
const bodyDataURL: string = await new Promise(res => {
1616
reader.addEventListener("load", () => {
17-
res(reader.result);
17+
res(reader.result as string);
1818
});
1919
})
2020

0 commit comments

Comments
 (0)