Adding retried URL in retry error logs

This commit is contained in:
David Négrier 2021-12-04 18:30:12 +01:00
parent 2cfc504e9a
commit 492fd2ed4e

View file

@ -1,6 +1,6 @@
import axios from "axios";
import * as rax from "retry-axios";
import {errorStore} from "../Stores/ErrorStore";
import { errorStore } from "../Stores/ErrorStore";
/**
* This instance of Axios will retry in case of an issue and display an error message as a HTML overlay.
@ -15,19 +15,19 @@ axiosWithRetry.defaults.raxConfig = {
// You can detect when a retry is happening, and figure out how many
// retry attempts have been made
onRetryAttempt: err => {
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(err)
console.log(cfg)
console.log(`Retry attempt #${cfg?.currentRetryAttempt}`);
errorStore.addErrorMessage('Unable to connect to WorkAdventure. Are you connected to internet?', {
console.log(err);
console.log(cfg);
console.log(`Retry attempt #${cfg?.currentRetryAttempt} on URL '${err.config.url}'`);
errorStore.addErrorMessage("Unable to connect to WorkAdventure. Are you connected to internet?", {
closable: false,
id: "axios_retry"
id: "axios_retry",
});
},
};
axiosWithRetry.interceptors.response.use(res => {
axiosWithRetry.interceptors.response.use((res) => {
if (res.status < 400) {
errorStore.clearMessageById("axios_retry");
}