ui-router在状态改变时获取Http状态码

时间:2022-03-05 19:39:55

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

我需要获取Http请求状态代码(200,301,404)并手动执行下一步。

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

如何在ui-router状态更改中获取状态代码?

==update==

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

当使用ui-router获取ui-view时,我们将获得200个text / html进行渲染。

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

但我想检查响应是否是301重定向网址

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)

答案是答案吗? (自动重定向网址)

1 个解决方案

#1


2  

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

否.HTTP状态代码用于来自服务器的HTTP消息。它们与客户端路由框架无关。

#1


2  

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

否.HTTP状态代码用于来自服务器的HTTP消息。它们与客户端路由框架无关。