Angular 5 - How to redirect to an external url with specific headers?

流过昼夜 提交于 2019-12-22 01:17:16

问题


This is what I am trying to achieve with Angular :

this.headers = ...;

this.http.get(`${urlApi}`).subscribe(data => {
    // go to url with specific headers
}, err => {
    console.log(err);
});

When I get the response of a get request from my server, I want to redirect to an external url with specific headers, to be able communicate some information between two apps.

There must be a way to do this. I know it's not possible using window.location.href.


回答1:


From what I have learnt, this is a redirection, not a request : this means you can't add headers to your redirect.

But, what you can do, is send URL params to your second application.

In your URL, simply append

?param1=value1&param2=value2&param3=value3 /// etc.

At the end of your URL.



来源:https://stackoverflow.com/questions/47882425/angular-5-how-to-redirect-to-an-external-url-with-specific-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!