diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 22:17:15 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 22:17:15 -0400 |
commit | 20540a35be82c34cc3962de4f957d1aa43f8a2b0 (patch) | |
tree | a4d67686a1d323bab947fcf3a6d6c2575b576c3e /src/client/Network.ts | |
parent | e95387732e1fbff49ec035c3bec4b03324d814c8 (diff) |
finally transferred google credential management to database
Diffstat (limited to 'src/client/Network.ts')
-rw-r--r-- | src/client/Network.ts | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/src/client/Network.ts b/src/client/Network.ts index cb46105f8..75ccb5e99 100644 --- a/src/client/Network.ts +++ b/src/client/Network.ts @@ -2,24 +2,32 @@ 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 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; + } -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 |