Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requestURL = `${env.API_URL}/api/users/logout/${token.id}`;
try {
const response = yield call(request, requestURL, {
method: 'PUT',
credentials: 'same-origin',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
'CSRF-Token': readCookie('XSRF-TOKEN'),
},
});
response.success
? (yield put(successLogoutAction()), yield put(push('/login')))
: yield put(errorLogoutAction());
} catch (err) {
// yield put(errorLogoutAction());
}
}
export function* updateIntentName({ agent }) {
debug('updating Intent name');
yield put(a.savingUpdatedIntentName(true));
try {
const intent = yield select(selectIntent());
const originalIntent = yield select(selectOriginal());
yield call(axios.patch, `/api/intents/${agent}/intent/${originalIntent}`, {
intent,
});
yield put(a.setIntentName(intent));
yield put(push(`/agents/${agent}/intent/${intent}`));
} catch (error) {
debug(error.message);
} finally {
yield put(a.savingUpdatedIntentName(false));
// TODO Manually update the name change in the right places.
// eslint-disable-next-line no-restricted-globals
location.reload();
}
}
// Do something with response error
switch (error.response.status) {
case 375:
store.dispatch(
showSnackbar(error.response.data, { variant: 'warning' }),
);
// setTimeout(() => {
// localStorage.removeItem('token');
// localStorage.removeItem('user');
// store.dispatch(push('/login'));
// }, 1000);
break;
case 376:
store.dispatch(showSnackbar(error.response.data, { variant: 'error' }));
store.dispatch(push('/'));
break;
case 401:
store.dispatch(showSnackbar(error.response.data, { variant: 'error' }));
break;
case 475:
store.dispatch(showSnackbar(error.response.data)); // Updating to have prebuilt and then custom messages.
break;
default:
break;
}
return Promise.reject(error);
},
);
it('openFolderAsync', () => {
const data = [{ language: 'pt-BR', data: {} }];
return expectSaga(openFolderAsync, { data })
.put(actions.loadFolder(null))
.put(push('/folder'))
.put(actions.loadFolder(data))
.run();
});
export function* deleteAgent({ agent }) {
debug('Deleting agent');
yield put(a.deletingAgent(true));
try {
yield axios.delete(`/api/agents/${agent}`);
yield put(push('/agents'));
yield call(getAgents, { skip: true });
} catch (error) {
yield put(a.saveAgentFailure('Sorry something went wrong deleting that.'));
} finally {
yield put(a.deletingAgent(false));
}
}
cellClick: uid => dispatch(push(`/entities/${uid}`)),
},
function* addIntent({ agent, intent, stay, resolve }) {
debug('Adding Intent');
yield put(a.addingIntent(true));
try {
yield call(axios.post, `/api/intents/${agent}`, { intent });
yield put(a.addIntentSuccess(intent));
if (stay) {
yield put(reset('addIntent', 'intent'));
} else {
yield put(
push(
`/agents/${encodeURIComponent(agent)}/intent/${encodeURIComponent(
intent,
)}`,
),
);
}
} catch (error) {
yield put(
a.addIntentFailure(
"There was an error adding that intent. Perhaps It's a duplicate?",
),
);
} finally {
yield put(a.addingIntent(false));
resolve();
}
goTo: uid => {
dispatch(push(`${ownProps.match.params.groupid}/${uid}`));
},
dispatch,
export function* openFolderAsync({ data }: any) {
yield put(actions.loadFolder(null));
yield put(push('/folder'));
yield put(actions.loadFolder(data));
}
cellClick: route =>
dispatch(
push(
`/agents/${encodeURIComponent(
this.state.agent,
)}/intent/${encodeURIComponent(route)}`,
),
),
},