feat: delete all user chats

This commit is contained in:
Timothy J. Baek 2023-12-30 00:15:37 -08:00
parent ee8e7c300a
commit d5dc36b2a9
3 changed files with 189 additions and 123 deletions

View file

@ -191,3 +191,35 @@ export const deleteChatById = async (token: string, id: string) => {
return res;
};
export const deleteAllChats = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(token && { authorization: `Bearer ${token}` })
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err;
console.log(err);
return null;
});
if (error) {
throw error;
}
return res;
};