diff --git a/package.json b/package.json index 81c6b18..7bb8fe3 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { "name": "lemmy-js-client", - "version": "0.17.2-rc.21", + "version": "0.17.2-rc.22", "description": "A javascript / typescript client for Lemmy", "repository": "https://github.com/LemmyNet/lemmy-js-client", "license": "AGPL-3.0", "author": "Dessalines ", "main": "./dist/index.js", "types": "./dist/index.d.ts", - "files": ["/dist"], + "files": [ + "/dist" + ], "scripts": { "build": "tsc", "docs": "typedoc src/index.ts", @@ -15,8 +17,13 @@ "prepare": "yarn run build && husky install" }, "lint-staged": { - "*.{ts,tsx,js}": ["prettier --write", "eslint --fix"], - "package.json": ["sortpack"] + "*.{ts,tsx,js}": [ + "prettier --write", + "eslint --fix" + ], + "package.json": [ + "sortpack" + ] }, "dependencies": { "cross-fetch": "^3.1.5", diff --git a/src/http.ts b/src/http.ts index 5a7e71a..e5e36ce 100644 --- a/src/http.ts +++ b/src/http.ts @@ -145,9 +145,9 @@ enum HttpType { * Helps build lemmy HTTP requests. */ export class LemmyHttp { - private apiUrl: string; - private headers: { [key: string]: string } = {}; - private pictrsUrl: string; + #apiUrl: string; + #headers: { [key: string]: string } = {}; + #pictrsUrl: string; /** * Generates a new instance of LemmyHttp. @@ -155,11 +155,11 @@ export class LemmyHttp { * @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` . */ constructor(baseUrl: string, headers?: { [key: string]: string }) { - this.apiUrl = `${baseUrl}/api/${VERSION}`; - this.pictrsUrl = `${baseUrl}/pictrs/image`; + this.#apiUrl = `${baseUrl}/api/${VERSION}`; + this.#pictrsUrl = `${baseUrl}/pictrs/image`; if (headers) { - this.headers = headers; + this.#headers = headers; } } @@ -169,7 +169,7 @@ export class LemmyHttp { * `HTTP.GET /site` */ getSite(form: GetSite) { - return this.wrapper(HttpType.Get, "/site", form); + return this.#wrapper(HttpType.Get, "/site", form); } /** @@ -178,7 +178,11 @@ export class LemmyHttp { * `HTTP.POST /site` */ createSite(form: CreateSite) { - return this.wrapper(HttpType.Post, "/site", form); + return this.#wrapper( + HttpType.Post, + "/site", + form + ); } /** @@ -187,7 +191,7 @@ export class LemmyHttp { * `HTTP.PUT /site` */ editSite(form: EditSite) { - return this.wrapper(HttpType.Put, "/site", form); + return this.#wrapper(HttpType.Put, "/site", form); } /** @@ -196,7 +200,7 @@ export class LemmyHttp { * `HTTP.POST /user/leave_admin` */ leaveAdmin(form: LeaveAdmin) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/leave_admin", form @@ -209,7 +213,7 @@ export class LemmyHttp { * `HTTP.GET /modlog` */ getModlog(form: GetModlog) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/modlog", form @@ -222,7 +226,7 @@ export class LemmyHttp { * `HTTP.GET /search` */ search(form: Search) { - return this.wrapper(HttpType.Get, "/search", form); + return this.#wrapper(HttpType.Get, "/search", form); } /** @@ -231,7 +235,7 @@ export class LemmyHttp { * `HTTP.GET /resolve_object` */ resolveObject(form: ResolveObject) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/resolve_object", form @@ -244,7 +248,7 @@ export class LemmyHttp { * `HTTP.POST /community` */ createCommunity(form: CreateCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community", form @@ -257,7 +261,7 @@ export class LemmyHttp { * `HTTP.GET /community` */ getCommunity(form: GetCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/community", form @@ -270,7 +274,7 @@ export class LemmyHttp { * `HTTP.PUT /community` */ editCommunity(form: EditCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/community", form @@ -283,7 +287,7 @@ export class LemmyHttp { * `HTTP.GET /community/list` */ listCommunities(form: ListCommunities) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/community/list", form @@ -296,7 +300,7 @@ export class LemmyHttp { * `HTTP.POST /community/follow` */ followCommunity(form: FollowCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/follow", form @@ -309,7 +313,7 @@ export class LemmyHttp { * `HTTP.POST /community/block` */ blockCommunity(form: BlockCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/block", form @@ -322,7 +326,7 @@ export class LemmyHttp { * `HTTP.POST /community/delete` */ deleteCommunity(form: DeleteCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/delete", form @@ -335,7 +339,7 @@ export class LemmyHttp { * `HTTP.POST /community/remove` */ removeCommunity(form: RemoveCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/remove", form @@ -348,7 +352,7 @@ export class LemmyHttp { * `HTTP.POST /community/transfer` */ transferCommunity(form: TransferCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/transfer", form @@ -361,7 +365,7 @@ export class LemmyHttp { * `HTTP.POST /community/ban_user` */ banFromCommunity(form: BanFromCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/ban_user", form @@ -374,7 +378,7 @@ export class LemmyHttp { * `HTTP.POST /community/mod` */ addModToCommunity(form: AddModToCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/community/mod", form @@ -387,7 +391,11 @@ export class LemmyHttp { * `HTTP.POST /post` */ createPost(form: CreatePost) { - return this.wrapper(HttpType.Post, "/post", form); + return this.#wrapper( + HttpType.Post, + "/post", + form + ); } /** @@ -396,7 +404,7 @@ export class LemmyHttp { * `HTTP.GET /post` */ getPost(form: GetPost) { - return this.wrapper(HttpType.Get, "/post", form); + return this.#wrapper(HttpType.Get, "/post", form); } /** @@ -405,7 +413,7 @@ export class LemmyHttp { * `HTTP.PUT /post` */ editPost(form: EditPost) { - return this.wrapper(HttpType.Put, "/post", form); + return this.#wrapper(HttpType.Put, "/post", form); } /** @@ -414,7 +422,7 @@ export class LemmyHttp { * `HTTP.POST /post/delete` */ deletePost(form: DeletePost) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/delete", form @@ -427,7 +435,7 @@ export class LemmyHttp { * `HTTP.POST /post/remove` */ removePost(form: RemovePost) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/remove", form @@ -440,7 +448,7 @@ export class LemmyHttp { * `HTTP.POST /post/mark_as_read` */ markPostAsRead(form: MarkPostAsRead) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/mark_as_read", form @@ -453,7 +461,7 @@ export class LemmyHttp { * `HTTP.POST /post/lock` */ lockPost(form: LockPost) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/lock", form @@ -466,7 +474,7 @@ export class LemmyHttp { * `HTTP.POST /post/feature` */ featurePost(form: FeaturePost) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/feature", form @@ -479,7 +487,7 @@ export class LemmyHttp { * `HTTP.GET /post/list` */ getPosts(form: GetPosts) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/post/list", form @@ -492,7 +500,7 @@ export class LemmyHttp { * `HTTP.POST /post/like` */ likePost(form: CreatePostLike) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/like", form @@ -505,7 +513,7 @@ export class LemmyHttp { * `HTTP.PUT /post/save` */ savePost(form: SavePost) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/post/save", form @@ -518,7 +526,7 @@ export class LemmyHttp { * `HTTP.POST /post/report` */ createPostReport(form: CreatePostReport) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/post/report", form @@ -531,7 +539,7 @@ export class LemmyHttp { * `HTTP.PUT /post/report/resolve` */ resolvePostReport(form: ResolvePostReport) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/post/report/resolve", form @@ -544,7 +552,7 @@ export class LemmyHttp { * `HTTP.GET /post/report/list` */ listPostReports(form: ListPostReports) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/post/report/list", form @@ -557,7 +565,7 @@ export class LemmyHttp { * `HTTP.GET /post/site_metadata` */ getSiteMetadata(form: GetSiteMetadata) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/post/site_metadata", form @@ -570,7 +578,7 @@ export class LemmyHttp { * `HTTP.POST /comment` */ createComment(form: CreateComment) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment", form @@ -583,7 +591,7 @@ export class LemmyHttp { * `HTTP.PUT /comment` */ editComment(form: EditComment) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/comment", form @@ -596,7 +604,7 @@ export class LemmyHttp { * `HTTP.POST /comment/delete` */ deleteComment(form: DeleteComment) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/delete", form @@ -609,7 +617,7 @@ export class LemmyHttp { * `HTTP.POST /comment/remove` */ removeComment(form: RemoveComment) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/remove", form @@ -622,7 +630,7 @@ export class LemmyHttp { * `HTTP.POST /comment/mark_as_read` */ markCommentReplyAsRead(form: MarkCommentReplyAsRead) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/mark_as_read", form @@ -635,7 +643,7 @@ export class LemmyHttp { * `HTTP.POST /comment/like` */ likeComment(form: CreateCommentLike) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/like", form @@ -648,7 +656,7 @@ export class LemmyHttp { * `HTTP.PUT /comment/save` */ saveComment(form: SaveComment) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/comment/save", form @@ -661,7 +669,7 @@ export class LemmyHttp { * `HTTP.POST /comment/distinguish` */ distinguishComment(form: DistinguishComment) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/distinguish", form @@ -674,7 +682,7 @@ export class LemmyHttp { * `HTTP.GET /comment/list` */ getComments(form: GetComments) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/comment/list", form @@ -687,7 +695,7 @@ export class LemmyHttp { * `HTTP.GET /comment` */ getComment(form: GetComment) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/comment", form @@ -700,7 +708,7 @@ export class LemmyHttp { * `HTTP.POST /comment/report` */ createCommentReport(form: CreateCommentReport) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/comment/report", form @@ -713,7 +721,7 @@ export class LemmyHttp { * `HTTP.PUT /comment/report/resolve` */ resolveCommentReport(form: ResolveCommentReport) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/comment/report/resolve", form @@ -726,7 +734,7 @@ export class LemmyHttp { * `HTTP.GET /comment/report/list` */ listCommentReports(form: ListCommentReports) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/comment/report/list", form @@ -739,7 +747,7 @@ export class LemmyHttp { * `HTTP.GET /private_message/list` */ getPrivateMessages(form: GetPrivateMessages) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/private_message/list", form @@ -752,7 +760,7 @@ export class LemmyHttp { * `HTTP.POST /private_message` */ createPrivateMessage(form: CreatePrivateMessage) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/private_message", form @@ -765,7 +773,7 @@ export class LemmyHttp { * `HTTP.PUT /private_message` */ editPrivateMessage(form: EditPrivateMessage) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/private_message", form @@ -778,7 +786,7 @@ export class LemmyHttp { * `HTTP.POST /private_message/delete` */ deletePrivateMessage(form: DeletePrivateMessage) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/private_message/delete", form @@ -791,7 +799,7 @@ export class LemmyHttp { * `HTTP.POST /private_message/mark_as_read` */ markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/private_message/mark_as_read", form @@ -804,7 +812,7 @@ export class LemmyHttp { * `HTTP.POST /private_message/report` */ createPrivateMessageReport(form: CreatePrivateMessageReport) { - return this.wrapper< + return this.#wrapper< CreatePrivateMessageReport, PrivateMessageReportResponse >(HttpType.Post, "/private_message/report", form); @@ -816,7 +824,7 @@ export class LemmyHttp { * `HTTP.PUT /private_message/report/resolve` */ resolvePrivateMessageReport(form: ResolvePrivateMessageReport) { - return this.wrapper< + return this.#wrapper< ResolvePrivateMessageReport, PrivateMessageReportResponse >(HttpType.Put, "/private_message/report/resolve", form); @@ -828,7 +836,7 @@ export class LemmyHttp { * `HTTP.GET /private_message/report/list` */ listPrivateMessageReports(form: ListPrivateMessageReports) { - return this.wrapper< + return this.#wrapper< ListPrivateMessageReports, ListPrivateMessageReportsResponse >(HttpType.Get, "/private_message/report/list", form); @@ -840,7 +848,7 @@ export class LemmyHttp { * `HTTP.POST /user/register` */ register(form: Register) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/register", form @@ -853,7 +861,7 @@ export class LemmyHttp { * `HTTP.POST /user/login` */ login(form: Login) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/login", form @@ -866,7 +874,7 @@ export class LemmyHttp { * `HTTP.GET /user` */ getPersonDetails(form: GetPersonDetails) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user", form @@ -879,7 +887,7 @@ export class LemmyHttp { * `HTTP.GET /user/mention` */ getPersonMentions(form: GetPersonMentions) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/mention", form @@ -892,7 +900,7 @@ export class LemmyHttp { * `HTTP.POST /user/mention/mark_as_read` */ markPersonMentionAsRead(form: MarkPersonMentionAsRead) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/mention/mark_as_read", form @@ -905,7 +913,7 @@ export class LemmyHttp { * `HTTP.GET /user/replies` */ getReplies(form: GetReplies) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/replies", form @@ -918,7 +926,7 @@ export class LemmyHttp { * `HTTP.POST /user/ban` */ banPerson(form: BanPerson) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/ban", form @@ -931,7 +939,7 @@ export class LemmyHttp { * `HTTP.GET /user/banned` */ getBannedPersons(form: GetBannedPersons) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/banned", form @@ -944,7 +952,7 @@ export class LemmyHttp { * `HTTP.POST /user/block` */ blockPerson(form: BlockPerson) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/block", form @@ -957,7 +965,7 @@ export class LemmyHttp { * `HTTP.GET /user/get_captcha` */ getCaptcha(form: GetCaptcha) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/get_captcha", form @@ -970,7 +978,7 @@ export class LemmyHttp { * `HTTP.POST /user/delete_account` */ deleteAccount(form: DeleteAccount) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/delete_account", form @@ -983,7 +991,7 @@ export class LemmyHttp { * `HTTP.POST /user/password_reset` */ passwordReset(form: PasswordReset) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/password_reset", form @@ -996,7 +1004,7 @@ export class LemmyHttp { * `HTTP.POST /user/password_change` */ passwordChangeAfterReset(form: PasswordChangeAfterReset) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/password_change", form @@ -1009,7 +1017,7 @@ export class LemmyHttp { * `HTTP.POST /user/mark_all_as_read` */ markAllAsRead(form: MarkAllAsRead) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/mark_all_as_read", form @@ -1022,7 +1030,7 @@ export class LemmyHttp { * `HTTP.PUT /user/save_user_settings` */ saveUserSettings(form: SaveUserSettings) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/user/save_user_settings", form @@ -1035,7 +1043,7 @@ export class LemmyHttp { * `HTTP.PUT /user/change_password` */ changePassword(form: ChangePassword) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/user/change_password", form @@ -1048,7 +1056,7 @@ export class LemmyHttp { * `HTTP.GET /user/report_count` */ getReportCount(form: GetReportCount) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/report_count", form @@ -1061,7 +1069,7 @@ export class LemmyHttp { * `HTTP.GET /user/unread_count` */ getUnreadCount(form: GetUnreadCount) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/user/unread_count", form @@ -1074,7 +1082,7 @@ export class LemmyHttp { * `HTTP.POST /user/verify_email` */ verifyEmail(form: VerifyEmail) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/user/verify_email", form @@ -1087,7 +1095,7 @@ export class LemmyHttp { * `HTTP.POST /admin/add` */ addAdmin(form: AddAdmin) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/admin/add", form @@ -1102,7 +1110,7 @@ export class LemmyHttp { getUnreadRegistrationApplicationCount( form: GetUnreadRegistrationApplicationCount ) { - return this.wrapper< + return this.#wrapper< GetUnreadRegistrationApplicationCount, GetUnreadRegistrationApplicationCountResponse >(HttpType.Get, "/admin/registration_application/count", form); @@ -1114,7 +1122,7 @@ export class LemmyHttp { * `HTTP.GET /admin/registration_application/list` */ listRegistrationApplications(form: ListRegistrationApplications) { - return this.wrapper< + return this.#wrapper< ListRegistrationApplications, ListRegistrationApplicationsResponse >(HttpType.Get, "/admin/registration_application/list", form); @@ -1126,7 +1134,7 @@ export class LemmyHttp { * `HTTP.PUT /admin/registration_application/approve` */ approveRegistrationApplication(form: ApproveRegistrationApplication) { - return this.wrapper< + return this.#wrapper< ApproveRegistrationApplication, RegistrationApplicationResponse >(HttpType.Put, "/admin/registration_application/approve", form); @@ -1138,7 +1146,7 @@ export class LemmyHttp { * `HTTP.POST /admin/purge/person` */ purgePerson(form: PurgePerson) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/admin/purge/person", form @@ -1151,7 +1159,7 @@ export class LemmyHttp { * `HTTP.POST /admin/purge/community` */ purgeCommunity(form: PurgeCommunity) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/admin/purge/community", form @@ -1164,7 +1172,7 @@ export class LemmyHttp { * `HTTP.POST /admin/purge/post` */ purgePost(form: PurgePost) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/admin/purge/post", form @@ -1177,7 +1185,7 @@ export class LemmyHttp { * `HTTP.POST /admin/purge/comment` */ purgeComment(form: PurgeComment) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/admin/purge/comment", form @@ -1190,7 +1198,7 @@ export class LemmyHttp { * `HTTP.POST /custom_emoji` */ async createCustomEmoji(form: CreateCustomEmoji) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/custom_emoji", form @@ -1203,7 +1211,7 @@ export class LemmyHttp { * `HTTP.PUT /custom_emoji` */ async editCustomEmoji(form: EditCustomEmoji) { - return this.wrapper( + return this.#wrapper( HttpType.Put, "/custom_emoji", form @@ -1216,7 +1224,7 @@ export class LemmyHttp { * `HTTP.Post /custom_emoji/delete` */ async deleteCustomEmoji(form: DeleteCustomEmoji) { - return this.wrapper( + return this.#wrapper( HttpType.Post, "/custom_emoji/delete", form @@ -1229,7 +1237,7 @@ export class LemmyHttp { * `HTTP.Get /federated_instances` */ async getFederatedInstances(form: GetFederatedInstances) { - return this.wrapper( + return this.#wrapper( HttpType.Get, "/federated_instances", form @@ -1249,7 +1257,7 @@ export class LemmyHttp { const headers = {} as any; if ( !globalThis?.document?.cookie?.includes("jwt=") && - !this.headers?.Cookie?.includes("jwt=") + !this.#headers?.Cookie?.includes("jwt=") ) { headers.Cookie = `jwt=${auth}`; } @@ -1257,11 +1265,11 @@ export class LemmyHttp { let url: string | undefined = undefined; let delete_url: string | undefined = undefined; - const response = await fetch(this.pictrsUrl, { + const response = await fetch(this.#pictrsUrl, { method: HttpType.Post, body: formData as unknown as BodyInit, headers: { - ...this.headers, + ...this.#headers, ...headers, }, }); @@ -1270,8 +1278,8 @@ export class LemmyHttp { if (responseJson.msg === "ok") { const { file: hash, delete_token: deleteToken } = responseJson.files[0]; - delete_url = `${this.pictrsUrl}/delete/${deleteToken}/${hash}`; - url = `${this.pictrsUrl}/${hash}`; + delete_url = `${this.#pictrsUrl}/delete/${deleteToken}/${hash}`; + url = `${this.#pictrsUrl}/${hash}`; } return { @@ -1281,28 +1289,28 @@ export class LemmyHttp { }; } - private buildFullUrl(endpoint: string) { - return `${this.apiUrl}${endpoint}`; + #buildFullUrl(endpoint: string) { + return `${this.#apiUrl}${endpoint}`; } - private async wrapper( + async #wrapper( type_: HttpType, endpoint: string, form: BodyType ): Promise { let response: Response; if (type_ === HttpType.Get) { - const getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`; + const getUrl = `${this.#buildFullUrl(endpoint)}?${encodeGetParams(form)}`; response = await fetch(getUrl, { method: HttpType.Get, - headers: this.headers, + headers: this.#headers, }); } else { - response = await fetch(this.buildFullUrl(endpoint), { + response = await fetch(this.#buildFullUrl(endpoint), { method: type_, headers: { "Content-Type": "application/json", - ...this.headers, + ...this.#headers, }, body: JSON.stringify(form), }); diff --git a/tsconfig.json b/tsconfig.json index 61b8f21..d9c7f76 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "noImplicitAny": true, "lib": ["es2017", "es7", "es6", "dom"], "outDir": "./dist", - "target": "ES5", + "target": "ES2015", "experimentalDecorators": true, "strictNullChecks": true, "moduleResolution": "Node",