Pregunta

If have an Rest-Resource which can be down. In my App I will do a put to the Resource but before the put is performed I see an OPTIONS-Request which get an Error and the put is not performed. So I can not handle the error state of the put. How can I check that an Resource is not reachable? Or how can I disable the OPTIONS-Request? Or how can I interact with the OPTIONS-Request, to get the error from it.

¿Fue útil?

Solución

Options requests is for CORS request. The browser does a OPTIONS requests to see if the current method is allowed in the request type. This is the way CORS works. You can handle your error in your promise and check the error code to handle it appropriately. If you want to do it across your app try a interceptor.

http://djds4rce.wordpress.com/2013/08/13/understanding-angular-http-interceptors/ (PS I am the author of the article. shameless plug)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top