Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit e34682b

Browse files
committed
better error response for mailchimp
1 parent 74ac147 commit e34682b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Force ES connections to use protocol config option - @cewald (#303, #304)
2323
- Better handling of HTTP error codes provided by API client - #3151
2424

25+
### Changed
26+
- Error responses for mailchimp - (@andrzejewsky)
27+
2528
## [1.10.0] - 2019.08.12
2629

2730
### Added
@@ -74,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7477
- Support unicode characters in order requests - @lukeromanowicz (#201)
7578
- TravisCI configured for building and linting - @lukeromanowicz (#204)
7679
- Use Redis database from configuration in mage2vs - @Cyclonecode (#211)
77-
- Requests with invalid body result in HTTP code 400 instead of 500 - @AndreiBelokopytov (#220)
80+
- Requests with invalid body result in HTTP code 400 instead of 500 - @AndreiBelokopytov (#220)
7881
- `src/models/order.schema.json` was moved to `src/models/order.schema.js` to support regex transformation - @lukeromanowicz (#201)
7982

8083
## [1.8.4] - 2019.04.17

src/api/extensions/mailchimp-subscribe/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module.exports = ({ config, db }) => {
2121
json: true,
2222
headers: { 'Authorization': 'apikey ' + config.extensions.mailchimp.apiKey }
2323
}, (error, response, body) => {
24-
if (error) {
25-
console.error(error)
24+
if (error || response.statusCode !== 200) {
25+
console.error(error, body)
2626
apiStatus(res, 'An error occured while accessing Mailchimp', 500)
2727
} else {
2828
apiStatus(res, body.status, 200)
@@ -46,8 +46,8 @@ module.exports = ({ config, db }) => {
4646
json: true,
4747
body: { members: [ { email_address: userData.email, status: config.extensions.mailchimp.userStatus } ], 'update_existing': true }
4848
}, (error, response, body) => {
49-
if (error) {
50-
console.error(error)
49+
if (error || response.statusCode !== 200) {
50+
console.error(error, body)
5151
apiStatus(res, 'An error occured while accessing Mailchimp', 500)
5252
} else {
5353
apiStatus(res, body.status, 200)
@@ -73,8 +73,8 @@ module.exports = ({ config, db }) => {
7373
json: true,
7474
body: { members: [ { email_address: userData.email, status: 'unsubscribed' } ], 'update_existing': true }
7575
}, (error, response, body) => {
76-
if (error) {
77-
console.error(error)
76+
if (error || response.statusCode !== 200) {
77+
console.error(error, body)
7878
apiStatus(res, 'An error occured while accessing Mailchimp', 500)
7979
} else {
8080
apiStatus(res, body.status, 200)

0 commit comments

Comments
 (0)