Skip to content

Commit

Permalink
feat: выдавать ошибку, если в течение 2 секунд от навыка не было ответа
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Jul 8, 2018
1 parent a7d1c62 commit fb012da
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const state = () => ({

// app state
isProxy: process.env.isProxy,
timeout: 2000,
isBottomTests: false,
isConsoleRequests: false,
speechEngine: process.env.speechEngine,
Expand Down Expand Up @@ -208,9 +209,9 @@ export const actions = {
console.log('\n');
}
if (state.isProxy) {
responseData = await this.$axios.$post('/api/request', axiosData);
responseData = await this.$axios.$post('/api/request', axiosData, { timeout: state.timeout });
} else {
responseData = await this.$axios.$post(state.webhookURL, data);
responseData = await this.$axios.$post(state.webhookURL, data, { timeout: state.timeout });
}
if (state.isConsoleRequests) {
expandedLog({ response: responseData });
Expand All @@ -236,8 +237,9 @@ export const actions = {
});
}
} catch (err) {
const textPost = err.message.match(/timeout/) ? 'не ответил вовремя' : 'см. консоль';
commit(ADD_MESSAGE, {
text: 'Ошибка запроса к ' + state.webhookURL + ' (см. консоль)',
text: `Ошибка запроса к ${state.webhookURL} (${textPost})`,
author: '',
class: 'error'
});
Expand Down

0 comments on commit fb012da

Please sign in to comment.