i am trying to post title and article in laravel rest api i am getting this error
Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, null given, called in C:\xampp\htdocs\LaravelProject\cpapi\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1440
This is my route/api.php file of post article data
Route::post('articles', 'ArticleController@store');
Route::post('articles', function(Request $request) {
return Article::create($request->all);
});
Run Code Online (Sandbox Code Playgroud)
And this store function of ArticleController.php file
public function store(Request $request)
{
$article = Article::create($request->all());
return response()->json($article, 201);
}
Run Code Online (Sandbox Code Playgroud)
This is article model class …
我无法获得 accessToken,我需要在我的后端 api 中使用它。
当我尝试这个时,
googleLogin = () => {
GoogleSignin.signIn()
.then((data) => {
console.log("TEST "+JSON.stringify(data));
var postData = {
access_token: data.accessToken,
code: data.idToken,
};
let axiosConfig = {
headers: {
'Content-Type': 'application/json',
"Accept": "application/json",
}
};
....
//Backend api axios call
....
})
.then((user) => {
console.log("TEST G LOGIN 1 "+JSON.stringify(user))
})
.catch((error) => {
console.log("....."+JSON.stringify(error))
});
}
Run Code Online (Sandbox Code Playgroud)
得到这个回应,它不包括
accessToken
{
"scopes": ["https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/drive.readonly"],
"serverAuthCode": "4/jwE5LLLLLLa7-f33333jmMD2V978oyp44444eb9yGe_qhHnkXXXXXXXLFXKZlQdDzlH-iIJx_gzqlLLLLLL3Q0PP0",
"idToken": "...v65a4MCC-ZUQmys_wf_DoCOBJEMuI........",
"user": {
"photo": "https://lh3.googleusercontent.com/-tLLLLLyeS0KE/AAAMMMMAAAI/AAAAAAAAAAA/ACHi3reMhihoeTe_6NjL666666EUVU82Q/s96-c/photo.jpg",
"email": "test@gmail.com",
"familyName": "tech",
"givenName": "test", …Run Code Online (Sandbox Code Playgroud)