[Vuejs]-Vue resource, using the same form for inserts and updates

0👍

One simple option would be to create the request based on the conditions and then connect the remaining promises in a single chain:

    const request = (this.itemId > 0) ? myresource.update ? myresource.save;
    request({
      id: this.itemId // Make the save call ignore the id
    }, this.item).then(response => {
      // Shared code
    });

Leave a comment