The data sent from Laravel to view is transformed into a string.
This started to happen when I put the application on the host, but not all data is converted, for example id remains int, but banned is transformed into int.
Request from vue to laravel:
getUserInformations: function(){
axios.get(backend + '/api/fetchProfile', {
params: {
id: this.$route.params.id
}
}).then((response)=>{
if(response.data === "INVALID_USER"){
this.invalidUser = true;
}else{
this.user = response.data['data'];
this.invalidUser = false;
}
}).catch((error) =>{
console.log(error)
})
},
And this its what laravel return to request
public function fetchUserData(Request $request){
try{
$recived = auth()->userOrFail();
}catch(TymonJWTAuthExceptionsUserNotDefinedException $e){
error_log($e);
return response()->json(['error' => $e->getMessage()], 401);
}
$user = User::where('id', $recived['id'])->first();
return response()->json(['data' => $user]);
}
Recived data is:
admin:"0" //int - problem
banned:"0" // int - problem
birthday:"2021-01-13"
code_verify:"fugPlhf4asLgLHwLYnWQ"
created_at:"2021-01-10T19:17:20.000000Z"
email:"[email protected]" //string
fallowed:"[]" //array - problem
firstName:"Nicolaescu" //string
id:3 //int - that is ok
lastName:"Mihaita" //string
Please help i dont have any ideea how to solve that.
In the database the variables have the type written in the comment.
Thanks in advince, and please forgive me for my bad english.
Users table migration :
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('firstName');
$table->string('lastName');
$table->string('email')->unique();
$table->date('birthday');
$table->string('password');
$table->timestamps();
});
And secondary migration to add some columns:
Schema::table('users', function (Blueprint $table) {
$table->boolean('banned')->default(false);
$table->string('reason');
$table->integer("warnings")->default(0);
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…