Answers.Body: <p>Issue resolved. Having checked with Yii debug bar i could see that there was no $_post data with the request. It seems axios sends the data as JSON and not usual post data. Switching to vue-resource enabled me to post the data for craft to use, new code:</p>
  
  <pre><code>this.$http.post('', {
      [this.csrfName]: this.csrfToken,
      action: 'commerce/cart/update-cart',
      lineItems: {[id]: {'remove': 1}}
  }, {
      emulateJSON: true,
      headers: {
          'X-CSRF-Token': this.csrfToken
      }
  })
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-25T11:41:58.410Z
Answers.LastActivityDate: 2019-06-25T11:41:58.410Z
Answers.UserDisplayName: Dean Sanderson
Body: <p>I am attempting to delete a commerce line item with ajax request but nothing ever deletes. Am i doing something wrong? Vue function below:</p>
  
  <pre><code>removeLine(id) {
  
              axios.post('', {
                      [this.csrfName]: this.csrfToken,
                      action: 'commerce/cart/update-cart',
                      lineItems: {[id]: {'remove': true}}
              },
              {
                  headers: {
                      'X-CSRF-Token': this.csrfToken
                  },
              }).then(function (response) {
  
              }).catch(function (error) {
                  // handle error
                  console.log(error);
              }).finally(function () {
                  // always executed
              });
          }
  </code></pre>
  
Tags: <craft3><plugin-craftcommerce2>
Title: Delete commerce line item with Ajax
ThreadText: # Delete commerce line item with Ajax
  
  (Asked by: username_0 on 2019-06-25)
  
  I am attempting to delete a commerce line item with ajax request but nothing ever deletes. Am i doing something wrong? Vue function below:
  
  ```
  removeLine(id) {
  
              axios.post('', {
                      [this.csrfName]: this.csrfToken,
                      action: 'commerce/cart/update-cart',
                      lineItems: {[id]: {'remove': true}}
              },
              {
                  headers: {
                      'X-CSRF-Token': this.csrfToken
                  },
              }).then(function (response) {
  
              }).catch(function (error) {
                  // handle error
                  console.log(error);
              }).finally(function () {
                  // always executed
              });
          }
  
  ```
  
  **Tags:** craft3, plugin-craftcommerce2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-06-25. Score: 3
  
  Issue resolved. Having checked with Yii debug bar i could see that there was no $\_post data with the request. It seems axios sends the data as JSON and not usual post data. Switching to vue-resource enabled me to post the data for craft to use, new code:
  
  ```
  this.$http.post('', {
      [this.csrfName]: this.csrfToken,
      action: 'commerce/cart/update-cart',
      lineItems: {[id]: {'remove': 1}}
  }, {
      emulateJSON: true,
      headers: {
          'X-CSRF-Token': this.csrfToken
      }
  })
  
  ```
  
  
  ---
  
  