Answer the question
In order to leave comments, you need to log in
How to read stream+json responses from Vuejs?
I use (for now) axios and here is the code:
axios.get('http://localhost:8081/pets')
.then(response => {
this.pets = response.data;
})
axios.get('http://localhost:8081/pets')
.then(response => {
this.pets.push(response.data)
})
Answer the question
In order to leave comments, you need to log in
It looks like what I want to do is called SSE:
let es = new EventSource('http://localhost:8081/pets');
es.addEventListener('message', event => {
let data = JSON.parse(event.data);
this.pets.push(data);
}, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question