Fetch chat history from backend and render it on chat page load

This commit is contained in:
Debanjum Singh Solanky 2023-01-13 21:27:21 -03:00
parent 330febaa1a
commit 177756be7e

View file

@ -87,6 +87,16 @@
if (type_via_url)
document.getElementById("chat-type").value = type_via_url;
fetch('/api/beta/chat')
.then(response => response.json())
.then(data => data.response)
.then(chat_logs => {
// Render conversation history, if any
chat_logs.forEach(chat_log => {
renderMessage(chat_log.message, chat_log.by, new Date(chat_log.created));
});
});
// Set welcome message on load
renderMessage("Hey, what's up?", "khoj");