in space-slack-sync/client/src/app/service/fetch.ts [3:14]
export async function fetchFromServer<T>(path: string, method: string = 'GET', stringResponse: boolean = false): Promise<T> {
if (!spaceAuth.isUserTokenPresent()) {
throw `Request ${path} cannot be made: user token is absent`;
}
const rawResponse = await fetch(path, { method: method, headers: { "Authorization": "Bearer " + spaceAuth.getUserToken() } });
if (stringResponse) {
return await rawResponse.text() as T;
} else {
return await rawResponse.json();
}
}