I'm struggling to successfully make an HTTP request and either return the response object or a boolean value. I am having trouble handling errors as my `handleError` function is not functioning properly.
This is what my code currently looks like:
The service
updateProduct(product: Product): Promise<number> {
return this.http.put('/api/products/1' + product.id,product)
.toPromise()
.then(response => response.status)
.catch(this.handleError);
}
private handleError(error: any): Promise<any> {
//console.error('An error occurred', error); // for demo purposes only
return Promise.reject(error.message || error);
}
The save function
onSave(): void {
this.productService.updateProduct(this.product)
.then(() => this.goBack())
.catch(er => console.log(er));
}
What steps can I take to resolve this issue?