Angular HTTP调用:
login(){
const loginstring = 'https://<removed>.auth0.com/authorize?' +
'response_type=token&' +
'client_id=<removed>&' +
'connection=null&' +
'redirect_uri=<removed>';
this.http.get(loginstring, {observe: 'response'}).subscribe(
(req:any)=>{
console.log('this is the http response');
console.log(req);
});
}
响应:
不使用代码格式,因为没有它,它更容易阅读。
错误HttpErrorResponse {标题:HttpHeaders,状态:200,statusText:“ OK”,url:“ http://localhost:4200/”,确定:false,…}标题:HttpHeaders {normalizedNames:Map(0),lazyUpdate:null,lazyInit: ƒ}状态:200statusText:“确定” URL:“ http://localhost:4200/”确定:假名:“ HttpErrorResponse”消息:“ http://localhost:4200/解析期间的Http失败”错误:{错误:语法错误:JSON中位置0以外的意外标记proto:HttpResponseBase
httpclient默认返回响应的JSON,这是我正在积极研究的东西。但是我不确定如何解决此问题。
200
,因为您成功到达服务器,但是有效载荷存在问题。似乎您需要发送JSON,并发送以<
开头的不是JSON的内容。您可以使用此网站来检查是否发送有效的JSON:https://jsonformatter.curiousconcept.com/