Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从返回的URL获取参数_Angular_Typescript_Angular9 - Fatal编程技术网

Angular 从返回的URL获取参数

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?

我想使用以下类型脚本分析GET请求的结果:

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]);