简体   繁体   English

如何使用Angular5获取重定向URL

[英]How to get a redirect URL with Angular5

I get a temporary URL from a JSON server. 我从JSON服务器获得一个临时URL。

This temporary URL redirects to another (permanent) URL. 该临时URL重定向到另一个(永久)URL。

I want to get this redirect (permanent) URL to store it in my DB. 我想获得此重定向(永久)URL,以将其存储在数据库中。

Is it possible with Angular 5 ??? Angular 5有可能吗?

  1. So there are multiple scenarios that can work here ,if you can route.navigate to that url then you can use ActivatedRouteSnapshot in angular and send the post request to your server with the value of the activated route. 因此,在这里可以使用多种方案,如果您可以将route.navigate路由到该URL,则可以在angular中使用ActivatedRouteSnapshot并将发布的请求与激活的路由的值一起发送到服务器。
  2. The second scenario is directly hit the temporary url with your server request and in response send across the permanent url which can then be passed on in the next(response) which can be saved further in the database 第二种情况是直接用您的服务器请求命中临时URL,并作为响应通过永久URL发送,然后可以在next(response)中传递该URL,然后可以将其进一步保存在数据库中

I would have preferred to do it directly in Angular 5. 我宁愿直接在Angular 5中进行操作。

But finally, as suggested by JB and Vaibhav, I used a server on which I ran a PHP program. 但是最后,按照JB和Vaibhav的建议,我使用了运行PHP程序的服务器。 In this program, I get the the redirect URL with curl. 在此程序中,我获得了带有curl的重定向URL。

And I access this PHP program from Angular with HttpClient. 然后,我使用HttpClient从Angular访问此PHP程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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