简体   繁体   中英

Angular 2 get headers in onInit

I'm developing on an Angular2 project and I've a problem regarding headers in http request. This is my scenario: I've a main page already developed, in a project I can't work on, with a menu in which every item redirects on various pages I'm developing. The main page, on every redirect call, sets a field in the header. Using Explorer developer tool I can see the first call on redirect with field setted in header and the http request is something like this:

https://myProject/main

My question is: can I get headers on onInit function of my page? I tried to make an http request to https://myProject/main in onInit function but it returns 302 error. Any suggestions?

EDIT: The main page is not part of my project.

I think you have to look into angular routing and navigation.

A http redirect call is not required unless the page you are trying to load is not developed within your application.

Angular routing and navigation reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM