diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-05-23 12:32:58 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-05-23 12:32:58 +0900 |
| commit | 8d3f9d7e34c2e19bf0602cd8a20bbd61cc9f744f (patch) | |
| tree | 5f5c3357803fdbbaf3dffc7d6d8846c9c23098b4 /src/api.ts | |
| parent | update test (diff) | |
| download | misskey-8d3f9d7e34c2e19bf0602cd8a20bbd61cc9f744f.tar.gz misskey-8d3f9d7e34c2e19bf0602cd8a20bbd61cc9f744f.tar.bz2 misskey-8d3f9d7e34c2e19bf0602cd8a20bbd61cc9f744f.zip | |
:v:
Diffstat (limited to 'src/api.ts')
| -rw-r--r-- | src/api.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/api.ts b/src/api.ts index 0a106ae914..e59ff1710d 100644 --- a/src/api.ts +++ b/src/api.ts @@ -33,14 +33,12 @@ export class APIClient { endpoint: E, data: Endpoints[E]['req'] = {}, credential?: string | null | undefined, ): Promise<Endpoints[E]['res']> { const promise = new Promise<Endpoints[E]['res']>((resolve, reject) => { - // Append a credential - if (this.credential) (data as Record<string, any>).i = this.credential; - if (credential) (data as Record<string, any>).i = credential; - - // Send request this.fetch(`${this.origin}/api/${endpoint}`, { method: 'POST', - body: JSON.stringify(data), + body: JSON.stringify({ + ...data, + i: credential !== undefined ? credential : this.credential + }), credentials: 'omit', cache: 'no-cache' }).then(async (res) => { |