From fcf0f5f6b52efc9d7c42d4968de5590554b042f9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Dec 2023 12:58:00 +0900 Subject: fix(frontend): disable Mk:apiExternal --- packages/frontend/src/scripts/api.ts | 48 ------------------------------------ 1 file changed, 48 deletions(-) (limited to 'packages/frontend/src/scripts/api.ts') diff --git a/packages/frontend/src/scripts/api.ts b/packages/frontend/src/scripts/api.ts index 0f54f779a6..8f3a163938 100644 --- a/packages/frontend/src/scripts/api.ts +++ b/packages/frontend/src/scripts/api.ts @@ -56,54 +56,6 @@ export function api( - hostUrl: string, - endpoint: E, data: P = {} as any, - token?: string | null | undefined, - signal?: AbortSignal, -): Promise> { - if (!/^https?:\/\//.test(hostUrl)) throw new Error('invalid host name'); - if (endpoint.includes('://')) throw new Error('invalid endpoint'); - pendingApiRequestsCount.value++; - - const onFinally = () => { - pendingApiRequestsCount.value--; - }; - - const promise = new Promise((resolve, reject) => { - // Append a credential - (data as any).i = token; - - const fullUrl = (hostUrl.slice(-1) === '/' ? hostUrl.slice(0, -1) : hostUrl) - + '/api/' + (endpoint.slice(0, 1) === '/' ? endpoint.slice(1) : endpoint); - // Send request - window.fetch(fullUrl, { - method: 'POST', - body: JSON.stringify(data), - credentials: 'omit', - cache: 'no-cache', - headers: { - 'Content-Type': 'application/json', - }, - signal, - }).then(async (res) => { - const body = res.status === 204 ? null : await res.json(); - - if (res.status === 200) { - resolve(body); - } else if (res.status === 204) { - resolve(); - } else { - reject(body.error); - } - }).catch(reject); - }); - - promise.then(onFinally, onFinally); - - return promise; -} - // Implements Misskey.api.ApiClient.request export function apiGet( endpoint: E, -- cgit v1.2.3-freya