I have a code which works perfectly fine but I have a question inside my head!
Is that code well written?
I am not that good with JavaScript but I start to learning few months ago and I am also studying good practices to keep my code clean and organised!
There is the code
export const getSources = ({ dispatch }, data) => {
return Api.getSources(data)
.then((response) => {
dispatch(types.GET_SOURCES, response.data);
return response;
})
.catch((response) => window.console.log('Could not get Sources List!'));
};
That is a actions from my Vuex and what really bothers me is the double return! That was the only option that I've found to get the response at my component!
Somebody can do it better and tells me how?
The method from my component where calls this action
fetchRecordList() {
this.getSources().then((response) => {
window.console.log(response);
});
},
Thanks in advance!