I have data in the store - an array of terms.

How to write a post-request to the server to synchronize terms (in the method of the component Vue) when the data is turned off.

PS How can I use Axios?

methods: { onTermCreate(newTerm) { const actionName = this.getModuleActionName('term', ACTIONS_NAMES.CREATE_TERM); this.$store.dispatch(actionName, newTerm).then(() => { // TODO add post request to sync terms state with server, then reset form // this.showPostRequestData(); this.resetForm(); }) }, addNewDataToExistingTerm(existingTerm, newTerm) { existingTerm.parents.push(newTerm); const actionName = this.getModuleActionName('term', ACTIONS_NAMES.UPDATE_TERM); this.$store.dispatch(actionName, existingTerm).then(() => { // TODO add post request to sync terms state with server, then reset form // this.showPostRequestData(); this.resetForm(); }) } } 
  • one
    What do you have as a backend that will receive a post request? Or more precisely, which parameters and how will it be read from the post? (json parameters or form-value?) - AK
  • @AK json parameters - Sveta Pershay

0