Trying to hit a WEB API through Angular http post method but unable to hit the web api and catch block is not throwing any error as well. I have enabled cross-origin policy as well. When I paste the web api url in th browser then it hits the method but not through angular http post function.
Below is the code component code
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this._http.post(this._commonUrl, filter, options)
.map(response => response.json())
.catch(this.handleError);
private handleError(error: Response) {
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
Controller code
[RoutePrefix("api/common")]
public class ProductController : ApiController
{
public ProductController()
{
}
[Route("initialize")]
[HttpPost]
public HttpResponseMessage SearchLazada(Filter filter)
{
try
{
}
}
}