diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-09-29 22:51:21 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-09-29 22:51:21 -0400 |
commit | 4643ee692e8d1913918a104e576eb71fb20f7130 (patch) | |
tree | 6171fcad1f78844cf97f4ed4da7f1472022a49f4 /src/client/Network.ts | |
parent | 0ae9a7f6acbdf6ecade8d349981e8d6badef7ff9 (diff) | |
parent | 70a46647b00849ece22a172aeaa886eb02e94706 (diff) |
fixed pdf uploading. merged.
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r-- | src/client/Network.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts new file mode 100644 index 000000000..75ccb5e99 --- /dev/null +++ b/src/client/Network.ts @@ -0,0 +1,33 @@ +import { Utils } from "../Utils"; +import { CurrentUserUtils } from "../server/authentication/models/current_user_utils"; +import requestPromise = require('request-promise'); + +export namespace Identified { + + export async function FetchFromServer(relativeRoute: string) { + return (await fetch(relativeRoute, { headers: { userId: CurrentUserUtils.id } })).text(); + } + + export async function PostToServer(relativeRoute: string, body?: any) { + let options = { + uri: Utils.prepend(relativeRoute), + method: "POST", + headers: { userId: CurrentUserUtils.id }, + body, + json: true + }; + return requestPromise.post(options); + } + + export async function PostFormDataToServer(relativeRoute: string, formData: FormData) { + const parameters = { + method: 'POST', + headers: { userId: CurrentUserUtils.id }, + body: formData, + }; + const response = await fetch(relativeRoute, parameters); + const text = await response.json(); + return text; + } + +}
\ No newline at end of file |