Handle centralized app state and registration + chat history

This commit is contained in:
Gabe Kangas
2022-05-02 17:45:22 -07:00
parent b590e4f765
commit a0354d6d49
11 changed files with 257 additions and 45 deletions

View File

@ -120,6 +120,8 @@ interface FetchOptions {
auth?: boolean;
}
export async function fetchData(url: string, options?: FetchOptions) {
const { data, method = 'GET', auth = true } = options || {};
@ -151,12 +153,22 @@ export async function fetchData(url: string, options?: FetchOptions) {
}
return json;
} catch (error) {
console.error(error);
return error;
// console.log(error)
// throw new Error(error)
}
}
export async function getUnauthedData(url: string, options?: FetchOptions) {
const opts = {
method: 'GET',
auth: false,
...options,
};
return fetchData(url, opts);
}
export async function fetchExternalData(url: string) {
try {
const response = await fetch(url, {