0

This is my code:

axios.post(currentUrl + this.data_source_url + "/create", {
    'date': this.item_data.date,
    'type_id': this.item_data.type_id,
    'value': this.item_data.value,
     this.id_name: this.id,  <------
    '_method': 'post',
});

I tried 'String text ${expression}' but this didn't work

Is it possible to use the this.id_name variable as a string in this axios call

0

1 Answer 1

0

You can use a computed property name:

axios.post(currentUrl + this.data_source_url + '/create', {
  date: this.item_data.date,
  type_id: this.item_data.type_id,
  value: this.item_data.value,
  [this.id_name]: this.id, // <------
  _method: 'post'
})
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.