diff options
| author | bobzel <zzzman@gmail.com> | 2025-03-06 16:17:47 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-03-06 16:17:47 -0500 |
| commit | 5ad858090f3006631062877d90120e3cc505fada (patch) | |
| tree | 9f87a8e1e7098a1025f6f4aac332dbc854db5be3 /src/client/Network.ts | |
| parent | 9c2a7c14fd9d0e44609aab30c6323583162009db (diff) | |
| parent | adaa107aac8558fa6f46e6ba1263c650c212d506 (diff) | |
Merge branch 'master' into aarav_edit
Diffstat (limited to 'src/client/Network.ts')
| -rw-r--r-- | src/client/Network.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts index 3b0406141..a2ecf1bea 100644 --- a/src/client/Network.ts +++ b/src/client/Network.ts @@ -1,5 +1,4 @@ import formidable from 'formidable'; -import * as requestPromise from 'request-promise'; import { ClientUtils } from '../ClientUtils'; import { Utils } from '../Utils'; import { Upload } from '../server/SharedMediaTypes'; @@ -16,13 +15,17 @@ export namespace Networking { } export function PostToServer(relativeRoute: string, body?: unknown) { - const options = { - uri: ClientUtils.prepend(relativeRoute), + return fetch(ClientUtils.prepend(relativeRoute), { method: 'POST', - body, - json: true, - }; - return requestPromise.post(options); + headers: { + 'Content-Type': 'application/json', + }, + body: body ? JSON.stringify(body) : undefined, + }).then(async response => { + if (response.ok) return response.json() as object; + + return await response.text().then(text => ({ error: '' + response.status + ':' + response.statusText + '-' + text })); + }); } /** |
