Typescript error on API post call
Am trying to do a post api call in a component but getting this error
Type '{ first_name: string; last_name: string; email: string; role: string; }' has no properties in common with type 'AxiosRequestConfig'
is this a bad way of doing it?
But if I do it through the store its ok, should i be doing all the api calls through the store?
issue is I need the API response on that component
Replies (2)
Am using metronic 8.1.1 vue version
Hi George,
Thank you for contacting our support.
To fix the typescript issue you need to wrap your data with params.
{
params: {
// your data here
}
}
Mostly you need to use vuex store when you want to share your data between multiple components.
You can read more about vuex usage in official doc: https://vuex.vuejs.org/#when-should-i-use-it
You can make API calls in the vuex module and then assign a response to the vuex state and after a state is set get the vuex state inside your component. See doc https://vuex.vuejs.org/guide/state.html#getting-vuex-state-into-vue-components
Regards,
Lauris Stepanovs,
Keenthemes Support Team