I have a Vue 3 website showing a list fetched from a REST-API (using the fetch method). Then sometimes this list is modified in the original DB and I would like to update my vue component accordingly. The good news is that a webhook is posted to me by the DB service when an entry is modified. However, I do not know how to consume this webhook in my Vue project.
I know how to consume it with an express server with something like
app.post("/hook", (req, res) => {
console.log(req.body)
}
but I don't see how to connect this with my Vue app ?
Maybe it's not even a good approach.
CodePudding user response:
A client-side app cannot react to a webhook per se.
You will need some kind of polling or socket communication like:
- long polling
- server sent events
- websockets