diff --git a/ts/graphs/WithGraphData.svelte b/ts/graphs/WithGraphData.svelte index 674ef6d28..04a33cfd6 100644 --- a/ts/graphs/WithGraphData.svelte +++ b/ts/graphs/WithGraphData.svelte @@ -38,9 +38,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ): Promise { await postRequest( "/_anki/setGraphPreferences", - new TextDecoder().decode( - pb.BackendProto.GraphPreferences.encode(prefs).finish() - ) + pb.BackendProto.GraphPreferences.encode(prefs).finish() ); } diff --git a/ts/lib/postrequest.ts b/ts/lib/postrequest.ts index a3075361b..d36b3cdeb 100644 --- a/ts/lib/postrequest.ts +++ b/ts/lib/postrequest.ts @@ -1,9 +1,17 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -export async function postRequest(path: string, body: string): Promise { +export async function postRequest( + path: string, + body: string | Uint8Array +): Promise { + const headers = {}; + if (body instanceof Uint8Array) { + headers["Content-type"] = "application/octet-stream"; + } const resp = await fetch(path, { method: "POST", + headers, body, }); if (!resp.ok) {