Перед отправкой API-запроса на вставку я хочу проверить, существует ли элемент в магазине или нет, если нет, то только отправить запрос на вставку.
add(){
const item = {id: 4,name:'test1',description:'description'}
// here i want to check whether test1 already exist or not
this.store.add(item);
this.httpService.insert(item).subscribe(
result => {
this.messageService.handleSuccess('inserted');
this.store.updateId(id, result.id);
},
error => this.messageService.handleError('error on insert:', error)
);
может кто-нибудь помочь?