TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tridip Bhattacharjee
NA
1.2k
78.1k
What $httpProvider.interceptors.push does
Apr 11 2018 4:28 AM
i am new in angular when reading this article https://www.c-sharpcorner.com/UploadFile/ff2f08/token-based-authentication-using-Asp-Net-web-api-in-angularj/
i found few line of code which is not clear to me. those lines are
.config([
'$httpProvider'
, function ($httpProvider) {
$httpProvider.interceptors.push(function ($q, $rootScope, $window, $location) {
return
{
request: function (config) {
return
config;
},
requestError: function (rejection) {
return
$q.reject(rejection);
},
response: function (response) {
if
(response.status ==
"401"
) {
$location.path(
'/login'
);
}
//the same response/modified/or a new one need to be returned.
return
response;
},
responseError: function (rejection) {
if
(rejection.status ==
"401"
) {
$location.path(
'/login'
);
}
return
$q.reject(rejection);
}
};
});
please some one help me to understand the above few lines of code and their objective.
Reply
Answers (
2
)
Why angular is called framework
typehead is not function in angular5