array that I want to save on the server with axios.
The data is like this:
data = {"data1": data1, "data2": data2};
Where data1 and data2 are both arrays.
On the server, my database table is like this:
$table->interger('id');
$table->text('data1')->nullable();
$table->text('data2')->nullable ();
$table->unsignedInteger('user_id');
And I set the fillable in the model for data1 and data2.
Do I still to do json.stringify on both data at the frontend before sending to data?
Please help me out.
You must do stringify in js for sending it to the server, and json_encode before you put it in the database
Just use the response object which comes with a json helper method in it. It goes like this 'return response()->json(data)'
Обсуждают сегодня