dimanche 23 juillet 2017

Pass multiple parameter by POST axios vue

I am trying to pass a props value and an form value to the backend controller using axios. But it only sends form value not the props value. My code is -

<template>
    <form @submit.prevent='onSubmit'>
        <div class="media-comment">
            <input type="text" v-model='form.comment' class="form-control" placeholder="comment...">
        </div>
    </form>
</template>

<script>
    export default {
        props: ['postId'],

        data() {
            return {
                form: new Form({comment: ''}),
                id: this.postId
            }
        },

        methods: {
            onSubmit() {
                console.log(this.postId); // it shows the value in console but the value doesnt pass
                this.form
                    .post('comments', this.data)
                    .then(post => this.$emit('completed', comment));
            }
        }
    }
</script>

in console it shows only the comment, not the prop value:

enter image description here

How to pass both value ??

thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire