私はAngularJS 2を使用して単純な平均スタックアプリケーションを開発しています。jwt strategy + angular2-jwtヘルパーライブラリでpassportJSを使用しています。Angular2 JWT認証 - JWTは3つのパートに分かれていなければなりませんか?
ここに、ログインコードを扱う私の角度コードがあります。私はAPIをテストして、それは機能します(郵便配達員と共に)。私は、ログインボタンを提出する際
//login.component.ts:
onSubmit(credentials):void {
console.log("on SUbmit here");
this._userService.login(credentials.email, credentials.password)
.subscribe((result) => {
if (result) {
console.log("Link to Todo?");
this._router.navigate(['TodoComponent']);
}
});
}
//user.service.ts:
signUp(firstName, lastName, email, password) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let user = new URLSearchParams();
user.set('email', email);
user.set('password', password);
user.set('firstName', firstName);
user.set('lastName', lastName);
return this._http
.post('/signup', user.toString(), { headers })
.map(res => res.json())
.map((res) => {
console.log(res.success);
return res.success;
});
}
はしかし、私はこのエラーを取得する:
Uncaught (in promise): Error: JWT must have 3 parts
私はJWTsが正しい形式で指定されていることを確認し、避けるために何をすべきこれらのエラー?