我有此在控制器:如何將json reponse從laravel返回到角?
public function index(Request $request){
$email = $request->email;
$password = $request->password;
if (!$email || !$password) {return redirect()->back();}
if (Auth::attempt(['email' => $email, 'password' => $password])) {
// Authentication passed...
$this->loggedUser = Auth::user();
if($this->loggedUser){
return response()->json(['isLoggedIn' => true],200);
}
}
return response()->json(['isLoggedIn' => false],200);
}
在角我有此:
Login (body: Object): Observable<Login[]> {
let bodyString = JSON.stringify(body); // Stringify payload
let options = new RequestOptions({ headers: this.headers }); // Create a request option
return this.http.post('/index', body, options) // ...using post request
.map(response => {return response} ,console.log('aaa')) // ...and calling .json() on the response to return data
.catch((error:any) => Observable.throw(error.json().error || 'Server error')); //...errors if any
}
問題是,當我在瀏覽器響應打開我收到此:
棄用:自動填充 $ HTTP_RAW_POST_DATA已被棄用,將來會被刪除 版本。爲避免此警告,在php.ini中將'always_populate_raw_post_data'設置爲 '-1',並改用php://輸入流。在上線 未知
警告:不能 修改標題信息 - 在未知已經發送了頭就 線
{ 「isLoggedIn」:假
}
任何建議如何解決這個問題,以便我得到json?
還怎麼是你服務器配置?它是一個無用的盒子,或者像WAMP或MAMP的東西? –
即時通訊使用xamp ..但現在即時通訊使用命令php artisan serve --host = 0這就是我如何運行我的項目,因爲我的角 – uzhas