add nav item and page for chat; set up data table of messages

This commit is contained in:
gingervitis
2020-12-22 22:05:17 -08:00
parent d944eeff9f
commit 05b9634180
3 changed files with 157 additions and 1 deletions

View File

@@ -34,10 +34,14 @@ export const LOGS_ALL = `${API_LOCATION}logs`;
// Get warnings + errors
export const LOGS_WARN = `${API_LOCATION}logs/warnings`;
// Chat history
export const CHAT_HISTORY = `${NEXT_PUBLIC_API_HOST}api/chat`;
const GITHUB_RELEASE_URL = "https://api.github.com/repos/owncast/owncast/releases/latest";
export async function fetchData(url) {
let options: RequestInit = {};
const options: RequestInit = {};
if (ADMIN_USERNAME && ADMIN_STREAMKEY) {
const encoded = btoa(`${ADMIN_USERNAME}:${ADMIN_STREAMKEY}`);
@@ -62,6 +66,21 @@ export async function fetchData(url) {
return {};
}
export async function fetchDataFromMain(url) {
try {
const response = await fetch(url);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
const json = await response.json();
return json;
} catch (error) {
console.log(error)
}
return {};
}
export async function getGithubRelease() {
try {
const response = await fetch(GITHUB_RELEASE_URL);