After carefully reviewing your explanation and the coding conventions utilized in the snippet you provided, I have a few key suggestions that may offer some insight.
If the main purpose of your filterPeople() function is to filter and update the view, it's possible that you are approaching this task from the wrong angle.
In the absence of full knowledge regarding the operations of the filterPeople() function, my advice would be to consider defining a vue.js filter if your intention is indeed to conduct a filtering operation. For instance, let's assume you wish to apply the filterPeople filter on the list of participants returned.
Vue.filter('filterPeople', function (newer, older) {
if (older == newer) {
return older
}
// Otherwise, proceed with filtering and return 'newer'
});
var endpoint = '/users/participants';
new Vue ({
el: '#app',
data: {
participants: null,
previous: null
},
methods:{
getParticipants: function(){
this.$http.get(endpoint).then(function(response){
this.previous = this.particpants;
this.participants = response.data;
},
function(error){
console.log(error.statusText);
}
})
},
mounted: function () {
this.getParticipants();
}
});
A typical representation within your html might resemble the following example.
<div id="app">
{participants | filterPeople(previous)}
<div>
This approach is merely a suggested course of action (represented in pseudo code format). Another viable option could involve using a v-if directive to display the binding effects with or without the filter.
Furthermore, there appears to be a discrepancy where you reference a getParticipants endpoint while employing an HTTP post method. Ideally, I would recommend naming the endpoint as /users/participants and utilizing a GET method for retrieving participants, along with a POST method (on the same endpoint) that accepts a JSON request body for participant creation. Naming an endpoint based on an action like getParticipants is less than optimal; instead, endpoints should reflect the resource they pertain to. Web service "methods" typically align more closely with SOAP principles.