shigg shigg - 4 months ago 6x
Javascript Question

Ajax post req of array item gives me a null response

As the title says, I can send a post request for a non array item using Vue Resource with no problem.

When it comes to sending an array data the response is a null array.Why is this happening?

var customizedExercises = this.customizedExercises;
this.$'/api/customized-exercises', customizedExercises).then(function(response){
}, function(response){
return response;

addSelectbox: function(){
this.customizedExercises.push({ weight:'',sets_duration:'',name:'',reps:'',exercise_day_id:'' })


customizedExercises : [
{ weight:'',sets_duration:'',name:'',reps:'',exercise_day_id:'' }


<button type="submit" @click="addSelectbox">add select box</button>
<div v-for=" customizedExercise in customizedExercises" class="input-group">

<span class="input-group-addon">
<select class="selectpicker form-control" v-model="" name="name" id="name">
<option value="{{ }}" v-for="exercise in exercises">{{ }}</option>

<span class="input-group-addon">
<select class="selectpicker form-control" v-model="customizedExercise.sets_duration" name="sets_duration" id ="sets_duration">
<option v-for="number in numbers" value="{{number}}">{{number}}</option>

<span class="input-group-addon">
<select class="selectpicker form-control" v-model="customizedExercise.weight" name="weight" id="weight">
<option v-for="number in numbers" value="{{number}}">{{number}}</option>


<input type="hidden" name="exercise_day_id" v-model="customizedExercise.exercise_day_id" id="exercise_day_id" value="1" />


Route::post('/api/customized-exercises',function() {
$inputs = Request::json()->all();

return $inputs;



You need to pass the array of objects into a JSON before sending it over to PHP.

customizedExercises = JSON.stringify(this.customizedExercises);