enh: channel delete

This commit is contained in:
Timothy Jaeryang Baek
2024-12-22 23:15:29 -07:00
parent 7ad8918cd9
commit 4c756b5501
4 changed files with 73 additions and 1 deletions
+31
View File
@@ -134,6 +134,37 @@ export const updateChannelById = async (token: string = '', channel_id: string,
return res;
}
export const deleteChannelById = async (token: string = '', channel_id: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/channels/${channel_id}/delete`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err.detail;
console.log(err);
return null;
});
if (error) {
throw error;
}
return res;
}
export const getChannelMessages = async (token: string = '', channel_id: string, page: number = 1) => {
let error = null;