Angular 从返回的URL获取参数
我想使用以下类型脚本分析GET请求的结果:Angular 从返回的URL获取参数,angular,typescript,angular9,Angular,Typescript,Angular9,我想使用以下类型脚本分析GET请求的结果: return this.httpClient .get('http://localhost:8080', options) .pipe( map((response: Response) => { console.log(response) }) ); 我想从重定向的http响应中获取code值:http://localhost:9000/callback?
return this.httpClient
.get('http://localhost:8080', options)
.pipe(
map((response: Response) => {
console.log(response)
})
);
我想从重定向的http响应中获取
code
值:http://localhost:9000/callback?code=7CLwgh
。如何获取值?您可以使用拆分字符串
var str="http://localhost:9000/callback?code=7CLwgh";
var sp=str.split("code=");
console.log(sp[1]);