I want to delete this data, but I failed.
What do you mean by removing the data? What do you actually want to remove? Would recommend looking here too: How do I ask a good question?
In case you just want to remove /api/client/illy
you can just delete the line.
data is not updated when I write another data on it
client.on("message",async(message) => {
if(message.content !== "web!login") return
app.get("/api/client/illy", (req, res) => res.status(200).end(message.author.username))
})
Maybe try using .send(yourdata)
instead of .end(yourdata)
to send the data to the user
.end
works the exact same as .send
, that is none of the problems, except .end also ends the buffers and sends the data. .send
will eventually call .end
.
Never heard of .end()
I thought it might of been a typo Very interesting, I will remember that!
If I have got this right, after reading a little about it, you use .end
if you want to end the response without any data, but you can put data in it anyway and it does the exact same thing as .send
cause that calls .end
anyway. Coding is so confusing
You can do something like:
const messages = new Collection();
client.on("message", message => messages.set(message.id, message));
app.get("/api/client/messages", (req, res) => res.end(JSON.stringify(messages.map(message => message.id))));
app.get("/api/client/messages/:id", (req, res) => res.end(JSON.stringify(messages.get(req.params.id))));