[Vuejs]-How to send data to api using vuejs

0👍

Just add v-model in your input tag and assign an dynamic variable like below.

<input type="text" name="delivery_time"  value="insert delivery time" v-model="<deliveryTime>">

V-model directive works as two way data binding hence whenever you will do any changes in input tag, it will get automatically reflected in variable . This value can be retrieved in your js part of component.

So you just need to pass that value, on the click of submit button.

this.$http.$post(url, {
    deliveryTime: deliveryTime
}, {
    // Config part( like authtoken
})

-1👍

I don’t have any idea for you way that you are doing.
You can use vue router + axios to handle your authentication.

Let read this to get more idea: https://www.smashingmagazine.com/2020/10/authentication-in-vue-js/

Leave a comment