【发布时间】:2019-11-26 05:10:21
【问题描述】:
成功登录后,我对每个请求的响应都未经授权
这是我的一些代码(如果您需要查看其他内容,请告诉我):
ionic 上的数据提供者
this.storageProvider.getToken().then(results => {
this.httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + results,
'Accept': 'application/json',
})
};
});
public getTodayReservations() {
//all reservations (not todays only)
let _url = this.url + '/guides/reservations/all';
return this.http.get(_url, this.httpOptions);
}
这是我的 laravel api 路由的配置:
Route::prefix('v1')
->group(function () {
Route::post('login', 'Api\UsersController@login');
Route::middleware('auth:api')
->prefix('guides')
->group(function () {
Route::get('/show', 'Api\UsersController@show');
Route::get('/reservations/today', 'Api\ReservationsController@today');
Route::get('/reservations/all', 'Api\ReservationsController@allRes');
});
});
请求标头:
Accept: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI.....
Content-Type: application/json
Origin: http://localhost:8100
Referer: http://localhost:8100/
【问题讨论】:
标签: laravel rest api ionic-framework ionic3