I assigned props to data in vue. But in created hook I am getting the values(group_id and subject_id) in data as undefined and that's why axios.post is giving me error. I found out that data function is called when vue instance is created, but there is still a little misconfusion. Is there any way to properly assign props to data so they can be used in created function?
props: ['name'], //props passed from route components
data:()=>({
group_id: name.split("_")[1],
subject_id: name.split("_")[2]
})
created(){
console.log(this.group_id, this.subject_id) //log is giving me undefineds
axios.post(`somelink`, { group_id: this.group_id, subject_id: this.subject_id })
}