diff --git a/server/index.js b/server/index.js
index 5b5949381c..8909035473 100644
--- a/server/index.js
+++ b/server/index.js
@@ -25,6 +25,10 @@ app.get('/convos', async (req, res) => {
res.status(200).send(await getConversations());
});
+app.get('/messages', async (req, res) => {
+ res.status(200).send(await getConversations());
+});
+
app.post('/ask', async (req, res) => {
console.log(req.body);
const { text, parentMessageId, conversationId } = req.body;
diff --git a/src/App.jsx b/src/App.jsx
index 929036d44a..832cc57ed8 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -4,18 +4,32 @@ import TextChat from './components/TextChat';
import Nav from './components/Nav';
import MobileNav from './components/MobileNav';
import useSWR from 'swr';
+import useSWRMutation from 'swr/mutation';
+import axios from 'axios';
const fetcher = (url) => fetch(url).then((res) => res.json());
const App = () => {
const [messages, setMessages] = useState([]);
+ const [convo, setConvo] = useState({ conversationId: null, parentMessageId: null });
const { data, error, isLoading, mutate } = useSWR('http://localhost:3050/convos', fetcher);
- console.log(data, isLoading);
+ const { trigger, isMutating } = useSWRMutation('http://localhost:3050/messages', fetcher, {
+ onSuccess: function (res) {
+ console.log('success', res);
+ // setMessages(res);
+ }
+ });
+
+ const onConvoClick = (conversationId, parentMessageId) => {
+ setConvo({ conversationId, parentMessageId });
+ trigger();
+ // console.log(e, e.target);
+ };
return (
{/*
*/}
-