[Vuejs]-How to return a JSON endpoint in Vue using axios

0👍

Basically, the json schema does not affect how you send data back to the backend server, it just enforces that the data (form data in this case) follows a certain structure. Therefor:

Simply look at your form v-model:

<v-jsf v-model="model" :schema="schema" :options="options" />

…which is model in this case. This variable holds your data. Now send it to the server in your submit method:

async returnJSON(){
  this.info = await this.$axios.post('<YOUR SERVER URL>', this.model).then(response => response.data)
}

Note that I changed your returnJSON method to use async/await syntax, which is far more understandable here and also made it use response.data aswell as called axios in the way I suspect you need to call it (depending on your setup).

Leave a comment