aboutsummaryrefslogtreecommitdiff
path: root/src/client/Network.ts
diff options
context:
space:
mode:
authorSam Wilkins <35748010+samwilkins333@users.noreply.github.com>2019-09-29 19:04:29 -0400
committerGitHub <noreply@github.com>2019-09-29 19:04:29 -0400
commit89fd714207dbd965dc4b566202ec85bbd7998adf (patch)
tree4b6279f1fe0157eb79fabd000a55754c33253506 /src/client/Network.ts
parentc40480ec1a2da84b4223b0605bea2fe19df1104c (diff)
parent5bd6158a1f839d19f8965bff97a908c89271437d (diff)
Merge pull request #289 from browngraphicslab/googlephotos_sharing_master
Googlephotos sharing master
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r--src/client/Network.ts33
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