Dear partners, I could solve my problem. First to all, I can not explain each line, but I eliminated the json options in the Web API, and I put the data in the URL as indicated by the documentation sent by @rapropos. Then, I wrote the call to eliminate as it explains the documentation and the example sent by @rlouie.
Coming up next, I paste the code, how I solved it.
In the first lines, where we write the import sentences, I declare a constant:
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'text/html; charset=UTF-8',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'DELETE, POST, GET, OPTIONS, PUT, HEAD',
'Access-Control-Allow-Headers': 'Content-Type' })};
Down, my method, where I delete the register. FavoriteProperty, is a class with the structure created for pass a personal type. In this case, FavoriteProperty, have 3 numeric fields as the table in the DB.
unSetFavorite(customerId: number, propertyId: number): Observable<FavoriteProperty>{
let UserIdAndPropertyId = customerId + ";" + propertyId;
return this.http.delete<FavoriteProperty>(this.apiUrl+'/favoriteproperty/'+UserIdAndPropertyId, httpOptions).pipe(
tap(_ => { console.log('Elimino la propiedad de favoritos'); }),
catchError(err => of('No se pudo eliminar la propiedad de favoritos'))).subscribe(err => console.log(err));
}
In other hand, this solution is partial, because, this setting for CORS, work only in IE, because when I launch ionic serve
, in Chrome, don’t work, because the WebAPI understand the method received as OPTIONS, and not as DELETE.
I hope be clear.
Regards, and thank very much.
Javier.