Skip to content

Commit 74c847b

Browse files
committed
added more uniqeness to the messages ids
1 parent f085535 commit 74c847b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎chat-app/backEnd/server.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express from "express";
22
import cors from "cors";
3+
import { randomUUID } from "crypto";
34

45
let messages = [
56
{
@@ -36,8 +37,9 @@ app.post("/sendMessage", (req, res) => {
3637
const { message, sender, replyTo } = req.body;
3738
if (message && sender) {
3839
const timestamp = Date.now();
40+
const id =
3941
messages.push({
40-
id: timestamp,
42+
id: randomUUID(),
4143
message,
4244
sender,
4345
timestamp,

0 commit comments

Comments
 (0)