summaryrefslogtreecommitdiff
path: root/packages/misskey-js/src/api.ts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2024-09-06 17:22:45 +0900
committerGitHub <noreply@github.com>2024-09-06 17:22:45 +0900
commit8d19bdbb65c79e2425bf5c73fd8b6310670a8c10 (patch)
treeb80183562a1befd90686f83b7b59ced5e03d6388 /packages/misskey-js/src/api.ts
parentrefactor(frontend): scss deprecated 警告に対応 (#14513) (diff)
downloadmisskey-8d19bdbb65c79e2425bf5c73fd8b6310670a8c10.tar.gz
misskey-8d19bdbb65c79e2425bf5c73fd8b6310670a8c10.tar.bz2
misskey-8d19bdbb65c79e2425bf5c73fd8b6310670a8c10.zip
fix(misskey-js): content-typeはapplication/jsonでないもののみを記録するように (#14508)
Diffstat (limited to 'packages/misskey-js/src/api.ts')
-rw-r--r--packages/misskey-js/src/api.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/misskey-js/src/api.ts b/packages/misskey-js/src/api.ts
index ea1df57f3d..659a29a221 100644
--- a/packages/misskey-js/src/api.ts
+++ b/packages/misskey-js/src/api.ts
@@ -56,6 +56,10 @@ export class APIClient {
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
}
+ private assertSpecialEpReqType(ep: keyof Endpoints): ep is keyof typeof endpointReqTypes {
+ return ep in endpointReqTypes;
+ }
+
public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(
endpoint: E,
params: P = {} as P,
@@ -63,9 +67,10 @@ export class APIClient {
): Promise<SwitchCaseResponseType<E, P>> {
return new Promise((resolve, reject) => {
let mediaType = 'application/json';
- if (endpoint in endpointReqTypes) {
+ if (this.assertSpecialEpReqType(endpoint) && endpointReqTypes[endpoint] != null) {
mediaType = endpointReqTypes[endpoint];
}
+
let payload: FormData | string = '{}';
if (mediaType === 'application/json') {
@@ -100,7 +105,7 @@ export class APIClient {
method: 'POST',
body: payload,
headers: {
- 'Content-Type': endpointReqTypes[endpoint],
+ 'Content-Type': mediaType,
},
credentials: 'omit',
cache: 'no-cache',