in vue , i have a service class [for doing axios class] which was previously written in javascript..now codebase is being migrated to full typescript....this module has to be migrated to typescript how can the below be a good typecript code?
import Axios from 'axios'
export default {
createStudent (name, age) {
return Axios.post('localhost:9090/student', { name: name , age: age })
}
}
I know i can just change the extension to ts and it wil all work...But want to the right code for this in typescript Should it be a class? This code is being called from vue class components and it abstracts out the axios calls into one place rather than polluting the vue component class.. If i make this as a typescript class , how can i use this in the vue class based components?should i inject or just create new?