Improve API hook
Change API hook so that it uses generic axios
function, e.g.
let config = {
url,
method,
timeout: TIMEOUT,
headers,
};
config = data ? { ...config, data } : config;
const result = await axios(config);
dispatch({ type: API_ACTIONS.SUCCESS, payload: result.data });
This will require to change tests and use something like
function mockConfig(url, data) {
let config = {
"url": url,
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"X-CSRFToken": null,
},
"timeout": 5000,
};
config = data ? { ...config, data } : config;
return config;
}
to track calls to mockAxios