Currently I can only jump to the error page when the request returns 404
// 创建拦截器
app.factory('Http404Interceptor', function ($q)
{
return {
responseError: function (response)
{
if(response.status == 404){
location.href = appURL.fullUrl + 'error';
}
return $q.reject(response);
}
}
});
// 配置拦截器给app
app.config(function ($httpProvider)
{
$httpProvider.interceptors.push('Http404Interceptor');
});
But the current requirement is to re-initiate the request to another link (such as: a.php) when the request returns 404. How should I write it so that the interceptor can realize this function?
Correction:
What does "request another link (such as: a.php)" mean? Request another
api
获取数据作为fallback
?If that’s what it means, isn’t it quite simple: