mirror of
https://github.com/owncast/owncast.git
synced 2025-11-01 19:32:20 +08:00
Handle centralized app state and registration + chat history
This commit is contained in:
@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user