diff --git a/models/Conversation.js b/models/Conversation.js index 6f95fbc1b1..e237b5ffcf 100644 --- a/models/Conversation.js +++ b/models/Conversation.js @@ -27,7 +27,7 @@ const Conversation = module.exports = { saveConversation: async ({ conversationId, parentMessageId, title }) => { - const messages = await Message.find({ conversationId }); + const messages = await Message.find({ conversationId }).exec(); const update = { parentMessageId, messages }; if (title) { update.title = title; @@ -39,7 +39,5 @@ module.exports = { { new: true, upsert: true } ).exec(); }, - getConversations: async () => { - return await Conversation.find({}).exec(); - }, + getConversations: async () => await Conversation.find({}).exec(), }; diff --git a/src/App.jsx b/src/App.jsx index 541f9ffb10..929036d44a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,14 +3,19 @@ import Messages from './components/Messages'; import TextChat from './components/TextChat'; import Nav from './components/Nav'; import MobileNav from './components/MobileNav'; +import useSWR from 'swr'; + +const fetcher = (url) => fetch(url).then((res) => res.json()); const App = () => { const [messages, setMessages] = useState([]); + const { data, error, isLoading, mutate } = useSWR('http://localhost:3050/convos', fetcher); + console.log(data, isLoading); return (