edoc
3 years ago

Api saving data

Posted 3 years ago by edoc

I am trying to save data from Vue using Vue resource.However, it seems like only timestamps and id are saved.

What am I doing wrong?Is it because I am trying to save an array of items?

Any help will be appreciated.

submit:function(){
                var customizedExercises = this.customizedExercises;
                this.$http.post('/api/customized-exercises', customizedExercises).then(function(){
                    console.log(JSON.stringify(customizedExercises));
                })
            },

api

Route::post('/api/customized-exercises',function() {
        return App\CustomizedExercise::create(Request::all());
    });

data

customizedExercises : [{ weight:'',reps_duration:'',name:'',sets:'' }],

data trying to save

[
    {"weight":"3","reps_duration":"2","name":"2","sets":"4"},     

         {"weight":"4","reps_duration":"3","name":"1","sets":"8"}
]

Please sign in or create an account to participate in this conversation.