I had this express.js code. As shown below:
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const randomMonth = months[Math.floor(Math.random() * months.length)];
app.get('/v1/month', (req, res) => {
res.json({ month: randomMonth })
});
But what happens is I always get the same response which is {"month":"July"}
.
How do I make it send a random response?
Aucun commentaire:
Enregistrer un commentaire