environment.API_URL = 'http://localhost:8080'
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
})
};
@Injectable({
providedIn: 'root'
})
export class LoginService {
private loginVerifyUrl = '/user/verify';
private fetchALL = '/user/fetch-all';
constructor(private http: HttpClient) { }
verifyLogin(email: string, password: string): Observable<any> {
return this.http.post<LoginToken>(environment.API_URL + this.loginVerifyUrl, {email, password}, httpOptions);
}
}
onSubmit() {
this.token.email = this.emailFormControl.value;
this.token.password = this.passwordFormControl.value;
this.loginService.verifyLogin(this.token.email, this.token.password).subscribe( data => {
console.log(data, 'is what we got from the server');
});
}
1
crs0910 2019-11-08 17:27:03 +08:00 1
你应该看浏览器请求找问题。
|
2
1KN6sAqR0a57no6s 2019-11-08 17:28:52 +08:00
这不是很明显的空指针问题吗
|
3
hahastudio 2019-11-08 17:29:54 +08:00 1
对比浏览器的请求和 Postman 的请求
|
4
wszgrcy 2019-11-08 17:52:30 +08:00 via Android 1
angular:出了什么问题都赖我?
url,method,请求头,cookie,请求体(如果有)都对比一遍 |
5
Immortal 2019-11-08 17:56:10 +08:00 1
应该是你代码里的请求和 postman 请求有些不一样 比如参数字段头信息等等 然后服务端数据校验不严格报错了 5xx 基本都是服务端错误的
|
6
Kamitora OP ![]( https://i.loli.net/2019/11/09/xMp6hQXdtFRJ1uf.png)
![]( https://i.loli.net/2019/11/09/tNKx6SEDA7ZvpQu.png) 找了几处不同,还是不知道怎么解决... |