Ola Prf! Estou pegando um erro quando clico em curtir mais de uma vez.
animais.service.ts
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, of, throwError } from 'rxjs'; import { catchError, mapTo } from 'rxjs/operators'; import { environment } from 'src/environments/environment'; import { TokenService } from '../autenticacao/token.service'; import { Animais, Animal } from './animais';
const API= environment.apiUrl; const NOT_MODIFIED = '304';
@Injectable({ providedIn: 'root' }) export class AnimaisService {
constructor(private http:HttpClient, private tokenService: TokenService) { }
listaDoUsuario(nomeDoUsuario:string): Observable {
return this.http.get(${API}/${nomeDoUsuario}/photos
);
}
buscaPorId(id:number): Observable{
return this.http.get(${API}/photos/${id}
);
}
excluiAnimal(id:number): Observable{
return this.http.delete(${API}/photos/${id}
);
}
curtirAnimal(id:number): Observable{
return this.http.post(${API}/photos/${id}/like
,
{},
{observe:'response'})
.pipe(mapTo(true),
catchError((error) => {
return error.status === NOT_MODIFIED ? of(false) : throwError(error);
}));
}
}
Por favor poderia avaliar o que possa ser? Obg!