Huei Tan
Huei Tan

Reputation: 2315

ui-router get Http Status Code when state change

I need to get the Http request status code (200,301,404) and manually do the next step.

How do I get the status code in ui-router state change?

==update==

When using ui-router to get ui-view, we will get 200 text/html to render.

But I want to check if the respond is 301 redirect url

What should I do on this

==update==

I found there is a paragraph

A response status code between 200 and 299 is considered a success status and will result
in the success callback being called. Note that if the response is a redirect, 
XMLHttpRequest will transparently follow it, meaning that the error callback will not be 
called for such responses.

from https://docs.angularjs.org/api/ng/service/$http

Is the the answer? (auto redirect url)

Upvotes: 2

Views: 1061

Answers (1)

Nate Abele
Nate Abele

Reputation: 5770

No. HTTP status codes are for HTTP messages, which come from servers. They have nothing to do with client-side routing frameworks.

Upvotes: 3

Related Questions