[Vuejs]-How send POST request of form Fetch Vuejs2

0👍

You have not used stored the value of input, you have to use v-model for that. For more info read Form Input Bindings.
You can try the below code

<select v-model="selected">
  <option disabled value="">Please select one</option>
  <option>Value 1</option>
  <option>Value 2</option>
  <option>Value 3</option>
</select>
<input v-model="name" placeholder="edit me">
export default {
  name: 'Index',
  data() {
    return {
      post: [],
      data: [],
      name:'',
      selected:''
    }
  },
  methods: {
    async PostReqests() {
      const request = await fetch("https://localhost:8000/addobject", {
        method: "POST",
        name: this.name, // sending the name input
        selected: this.selected // sending the option which was selected from dropdown
      })
      console.log(request)
    }
  }
}

Leave a comment