Commit 9b7d5e97 authored by Maksym Tishchenko's avatar Maksym Tishchenko
Browse files

API with timeout

parent 96ac450f
......@@ -109,11 +109,17 @@ export const logoutUserAction = () => ({
function* logoutUserSaga() {
clearCookiesInBrowser();
const appTokenData = yield call(LoginService.loginApp);
try {
clearCookiesInBrowser();
const appTokenData = yield call(LoginService.loginApp);
saveCookiesInBrowser({ ...appTokenData, ...jwt.decode(appTokenData.access_token) }, appTokenData.exp * 1000 || new Date().getTime() + appTokenData.expires_in * 1000);
window.location.replace(document.baseURI);
saveCookiesInBrowser({ ...appTokenData, ...jwt.decode(appTokenData.access_token) }, appTokenData.exp * 1000 || new Date().getTime() + appTokenData.expires_in * 1000);
window.location.replace(document.baseURI);
} catch (e) {
console.log('Error logging out', e.data?.error || e.toString())
clearCookiesInBrowser();
window.location.replace(document.baseURI);
}
}
......
......@@ -43,7 +43,7 @@ import { ApiError } from '@gringlobal-ce/client/model/common';
*/
const serviceAxios = axios.create({
baseURL: process.env.API_URL, // use embedded proxy
timeout: 0,
timeout: 30000,
withCredentials: true,
headers: {
'X-Custom-Header': 'Grin global client',
......
......@@ -6,6 +6,7 @@ import _isArray from 'lodash/isArray';
import _isObject from 'lodash/isObject';
import { ReportService } from '@gringlobal-ce/client/service';
import Mustache from 'mustache';
import { showSnackbar } from "@gringlobal-ce/client/action/snackbar";
// import { isObject } from 'util';
/**
......@@ -456,5 +457,8 @@ export function printPdfReport(endpoint: string, originalFilename: string, itemI
printWindow.focus();
}
return pdfReport;
}).catch((e) => {
console.log('Something went wrong', e.data && e.data.error || e.toString())
showSnackbar(e.data && e.data.error || e.toString())
})
}
......@@ -188,6 +188,8 @@ class CropDetailsPage extends React.Component<PropsFromRedux & WithTranslation &
.then((fileMeta) => {
updateFileMeta(fileMeta);
openDialog();
}).catch((e) => {
this.setState({ error: e.data && e.data.error || e.toString() })
})
}
......
......@@ -367,6 +367,9 @@ class CropTraitDetailsPage extends React.Component<PropsFromRedux & WithTranslat
updateFileMeta(fileMeta);
openDialog();
})
.catch((e) => {
this.setState({ error: e.data && e.data.error || e.toString() })
})
}
private handleSubmitCode = (data: TranslatedCropTraitCode) => {
......
......@@ -9,7 +9,7 @@ import { ApiError } from '@gringlobal-ce/client/model/common';
*/
const serviceAxios = axios.create({
baseURL: process.env.ORIGIN,
timeout: 0,
timeout: 30000,
withCredentials: true,
headers: {
'X-Custom-Header': 'Grin global client',
......
......@@ -71,6 +71,9 @@ class RegisterPage extends React.Component<IRegisterPage> {
this.setState({ captchaSiteKey: sysData.captchaSiteKey })
console.log(sysData)
})
.catch((e) => {
this.setState({ apiError: e.data && e.data.error || e.toString() })
})
}
public render() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment