From c66211f7c9bd2a6bcf75bd285fa6587081bd3d0d Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Fri, 12 May 2023 13:07:54 +0000 Subject: [PATCH] Fix body not serializing because of bigint (#119) * Fix body not serializing because of bigint * Use cleaner JSON handling --- src/http.ts | 5 +++++ src/websocket.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/http.ts b/src/http.ts index bdec8ec..7f46f70 100644 --- a/src/http.ts +++ b/src/http.ts @@ -130,6 +130,11 @@ import { VerifyEmail } from "./types/VerifyEmail"; import { VerifyEmailResponse } from "./types/VerifyEmailResponse"; import { UploadImage, UploadImageResponse, VERSION } from "./types/others"; +// @ts-ignore +BigInt.prototype["toJSON"] = function () { + return this.toString(); +}; + enum HttpType { Get = "GET", Post = "POST", diff --git a/src/websocket.ts b/src/websocket.ts index a33add4..d661776 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -87,6 +87,11 @@ import { TransferCommunity } from "./types/TransferCommunity"; import { UserJoin } from "./types/UserJoin"; import { VerifyEmail } from "./types/VerifyEmail"; +// @ts-ignore +BigInt.prototype["toJSON"] = function () { + return this.toString(); +}; + /** * Helps build lemmy websocket message requests, that you can use in your Websocket sends. *