diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 18:11:10 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 18:11:10 -0400 |
commit | e95387732e1fbff49ec035c3bec4b03324d814c8 (patch) | |
tree | a3392130fb8d8270f6792facc9a8557e4cb8d044 /src/client/Network.ts | |
parent | 10451e596f0b2032b3186286e6176b2c0cea4e52 (diff) |
beginning to read from and write to database
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r-- | src/client/Network.ts | 25 |
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 |