Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Fix #1210 and more issues by removing one level of "response" #1352

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/actions/EditMyTree.js
Expand Up @@ -36,11 +36,11 @@ export function editTree(plantContribution, plantId, navigation) {
dispatch(setProgressModelState(false));
updateRoute('app_userHome', navigation || dispatch);
})
.catch(error => {
debug(error.response);
.catch(response => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Promise must only reject with an Error. The only thing .catch can catch would be an Error.

putAuthenticatedRequest is .catching errors, handling that with onAPIError which then throws an Error. It does not throw a Response

debug(response);
dispatch(setProgressModelState(false));
NotificationManager.error(
error.response.data.message,
response.data.message,
i18n.t('label.error'),
5000
);
Expand Down Expand Up @@ -77,16 +77,16 @@ export function deleteContribution(plantContributionId) {
5000
);
})
.catch(err => {
debug(err);
.catch(response => {
debug(response);

NotificationManager.error(
error.response.data.message,
response.data.message,
i18n.t('label.error'),
5000
);

reject(err);
reject(response);
})
.finally(data => {
dispatch(setProgressModelState(false));
Expand Down
8 changes: 4 additions & 4 deletions app/actions/challengeActions.js
Expand Up @@ -31,12 +31,12 @@ export function challenge(challengeDetails) {
5000
);
})
.catch(error => {
debug('error: ', error);
reject(error);
.catch(response => {
debug('error: ', response);
reject(response);
dispatch(setProgressModelState(false));
NotificationManager.error(
error.response.data.message,
response.data.message,
i18n.t('label.error'),
5000
);
Expand Down
6 changes: 3 additions & 3 deletions app/containers/Challenge/createChallenge.js
Expand Up @@ -43,10 +43,10 @@ class ChallengeContainer extends Component {
challengeSuccess: true
});
})
.catch(err => {
console.log(err.response.data);
.catch(response => {
console.log(response.data);
this.setState({
error: err.response.data.minTarget
error: response.data.minTarget
});
});
}
Expand Down