@@ -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