Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.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 角度后html请求url_Angular - Fatal编程技术网

Angular 角度后html请求url

Angular 角度后html请求url,angular,Angular,我向oauth2发送http post。 我的角度是7 我的服务代码: import { Http, Headers, RequestOptions, ResponseContentType } from '@angular/http'; import { map } from 'rxjs/internal/operators/map'; const options = new RequestOptions({ headers: headers }); return this.htt

我向oauth2发送http post。 我的角度是7

我的服务代码:

import { Http, Headers, RequestOptions, ResponseContentType } from '@angular/http';
import { map } from 'rxjs/internal/operators/map';

const options = new RequestOptions({
    headers: headers
});

return this.http.post(url, data, options).pipe(
    map((res: any) => {
        return res.json();
}));

const-httpParams=new-httpParams()
.set('用户名',电子邮件)
.set('password',password);
console.log('goodtosendpost');
返回this.http.post(oauthservice.com/oauth,httpParams)
.map((response:response)=>response.json());
在我的组件中,我得到了我的服务功能

this.authService.login(this.f.email.value,this.f.password.value)。订阅(
数据=>{
console.log(data);//调用返回的数据
},
错误=>{
console.log(错误);//如果有错误
},
() => {
});
我的错误消息是:

error: SyntaxError: "JSON.parse: unexpected character at line 24 column 1 of the JSON data"
text: text: "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<html>\n<head>\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>WSO2 Identity Server</title>\n    \n    <link rel=\"icon\" href=\"images/favicon.png\" type=\"image/x-icon\"/>\n    <link href=\"libs/bootstrap_3.3.5/css/bootstrap.min.css\" rel=\"stylesheet\">\n    <link href=\"css/Roboto.css\" rel=\"stylesheet\">

如何从中获取请求Url以重定向到此页面?

尝试分配任何类型的接收数据

this.authService.login(this.f.email.value, this.f.password.value).subscribe((data:any) => {
        console.log(data); // Data which is returned by call
      },(error:any) => {
        console.log(error); // Error if any
      });

以JSON对象的形式返回响应

服务代码:

import { Http, Headers, RequestOptions, ResponseContentType } from '@angular/http';
import { map } from 'rxjs/internal/operators/map';

const options = new RequestOptions({
    headers: headers
});

return this.http.post(url, data, options).pipe(
    map((res: any) => {
        return res.json();
}));

服务功能:

this.authService.login(username, password).subscribe((res: any) => {
    console.log(res);
}, (err: any) => {
    console.log(err);
});

成功登录后,它将重定向到带有代码的重定向url。。。。使用代码您必须生成令牌,因为它是html响应而不是json,我总是会出现错误。问题是我调用的服务通过http get更改我的http post,我需要捕获此新url并将用户重定向到此。您使用WSO2对吗?如果必须创建回调函数,则需要检查API。