aboutsummaryrefslogtreecommitdiff
path: root/src/client/Network.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r--src/client/Network.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts
new file mode 100644
index 000000000..cb46105f8
--- /dev/null
+++ b/src/client/Network.ts
@@ -0,0 +1,25 @@
+import { Utils } from "../Utils";
+import { CurrentUserUtils } from "../server/authentication/models/current_user_utils";
+import requestPromise = require('request-promise');
+
+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