Skip to content

Commit c6d1062

Browse files
committed
-wrong data, its content not data
-fixed a glitched where the server returns an object, but the client parses it as text
1 parent e54af9e commit c6d1062

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/server.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,12 @@ async function handleApiRequest(req, res) {
226226
// Messaging API
227227
'send-message': async () => {
228228
const { content } = req.body;
229-
const message = content;
230-
if (!message) return res.status(400).send('Missing content');
229+
if (!content) return res.status(400).send('Missing content');
231230

232231
const id = Object.keys(db.messages).length + 1;
233232
const messageData = {
234233
id,
235-
message,
234+
content,
236235
user,
237236
timestamp: new Date().toISOString(),
238237
edited: false

static/tools/newMessages/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function fetchCurrentUser() {
2626
service: 'get-user'
2727
})
2828
});
29-
if (response.ok) currentUser = await response.text();
29+
if (response.ok) currentUser = await response.json(); currentUser = currentUser['user']
3030
} catch (error) {
3131
console.error('Error fetching user:', error);
3232
}

0 commit comments

Comments
 (0)