简体   繁体   中英

How to get a redirect URL with Angular5

I get a temporary URL from a JSON server.

This temporary URL redirects to another (permanent) URL.

I want to get this redirect (permanent) URL to store it in my DB.

Is it possible with 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.
  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

I would have preferred to do it directly in Angular 5.

But finally, as suggested by JB and Vaibhav, I used a server on which I ran a PHP program. In this program, I get the the redirect URL with curl.

And I access this PHP program from Angular with HttpClient.

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