Olá,
Estou tentando fazer a função dele no meu sistema mas ele meio que não concretiza o 'delete'. Coloquei dentro de um try cacth pra pegar o erro mas ele entra no try e não é me apresentado nenhum erro.
Excluir.component.ts
excluirProduto() {
this.id = '4';
console.log(this.id);
console.log(this.produtoService.deleteProduto(this.id).subscribe());
this.produtoService.deleteProduto(this.id).subscribe();
}
Produto.service.ts
deleteProduto(id: string): Observable<any> {
console.log('1');
try {
console.log('try');
const _url = `${this.url}/Excluir.php?id=${id}`;
console.log(_url);
console.log(this.http.delete<any>(_url));
const result = this.http.delete<any>(_url);
return result;
} catch (error) {
console.log('catch');
console.log(error);
}
}
Mensagem no console
try
https://minha-url/teste_api/Excluir.php?id=4
Ele entra no 'try', mostra a url com o id certo mas não faz o delete.
Se eu clicar nessa url ele faz o delete