await axios
.post(
executeBatch,
{
headers: {
"Content-Type": "application/json",
"x-access-token": localStorage.getItem("token"),
},
}
)
.then(
(response) =>
this.$store.commit(
"insertOutputFile",
response.data.outputFile._id
),
);
alert("You can download the result");
so sometimes i get empty response with status code 200, was thinking about retrying the request if that happens, am wondering what is the correct way to approach this issue.
I think axios interceptors will work for you.
axios.interceptors.response.use((response) => {
return response
},
async function(error) {
const originalRequest = error.config;
if () { // condition
originalRequest._retry = true;
}
}
)
You can create setupAxios file in your base redux directory and export it from index.js in your base redux directory.
export {default as setupAxios} from "./setupAxios";
And define setupAxios from your root index.js file
import * as _redux from "./redux";
_redux.setupAxios(axios, store);
Btw, I am using react.js, it could be a little different in vue.js.