Restangular CORS error is failing with status code of -1

62 Views Asked by At

The restangular docs states that the API with CORS error fails with a status code of 0, but mine is failing with -1.

From the docs:

This is typically caused by Cross Origin Request policy. In order to enable cross domain communication and get correct response with appropriate status codes, you must have the CORS headers attached, even in error responses. If the server does not attach the CORS headers to the response then the XHR object won't parse it, thus the XHR object won't have any response body, status or any other response data inside which typically will cause your request to fail with status code 0.

I have looked into similar questions on SO, but couldn't find anything related to this.

0

There are 0 best solutions below