forked from open-webui/open-webui
		
	feat: delete all user chats
This commit is contained in:
		
							parent
							
								
									ee8e7c300a
								
							
						
					
					
						commit
						d5dc36b2a9
					
				
					 3 changed files with 189 additions and 123 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue