I have an array of objects and when I insert a new one I want to know if is duplicate or not.
this.duplicate = false;
for(let item of this.items){
if(item.id && this.item.name === item.name) { // this.item.name is the value that I try to insert
//item.id (if is add, id = null, is update id = value)
this.$notify({
group: "notify",
text: "Duplicate value! ",
type: "error"
});
this.duplicate = true ;
}
}
if(!this.duplicate){
// post/put request
}
This works just for add (post request), on update I get always duplicate value.