Php 使用Laravel和Ionic登录
我是爱奥尼亚的新手,我需要将以下JSON帖子发送到我的后端Laravel应用程序Php 使用Laravel和Ionic登录,php,json,laravel,typescript,ionic-framework,Php,Json,Laravel,Typescript,Ionic Framework,我是爱奥尼亚的新手,我需要将以下JSON帖子发送到我的后端Laravel应用程序 { "user" : "amk1", "pwd" : "schule123" } 我已经在Postman中测试了它,我需要存储以下JWT令牌 {"message":"success", "jwt":"token"} 首先,如何将JSON请求从ionic发送到Laravel应用程序我在login.page.ts中这样做的 login(form) { this.authService.log
{
"user" : "amk1",
"pwd" : "schule123"
}
我已经在Postman中测试了它,我需要存储以下JWT令牌
{"message":"success",
"jwt":"token"}
首先,如何将JSON请求从ionic发送到Laravel应用程序我在login.page.ts中这样做的
login(form) {
this.authService.login(form.value).subscribe((res) => {
this.router.navigateByUrl('home');
});
}
在auth.service.ts中我写了这个
export class AuthService {
AUTH_SERVER_ADDRESS = 'http://127.0.0.1:8000/checklogin';
authSubject = new BehaviorSubject(false);
register: any;
constructor(private httpClient: HttpClient, private storage: Storage) { }
login(user: User): Observable<AuthResponse> {
return this.httpClient.post(`${this.AUTH_SERVER_ADDRESS}`, user).pipe(
tap(async (res: AuthResponse) => {
if (res.user) {
await this.storage.set('ACCESS_TOKEN', res.user.access_token);
await this.storage.set('EXPIRES_IN', res.user.expires_in);
this.authSubject.next(true);
}
})
);
}
那么,我遗漏了什么,以及如何存储用于身份验证的JWT令牌
error:
exception: "ErrorException"
file: "/Users/rotschaedl/DPA/tischreservierenp/app/Http/Controllers/MainController.php"
line: 124
message: "Undefined index: user"
trace: (56)
__proto__: Object