From 2bf05e6c859a0862924ad9e0e8cc8b2825e3b7c7 Mon Sep 17 00:00:00 2001 From: krcummings1 Date: Mon, 22 Apr 2024 12:57:21 -0600 Subject: [PATCH] added logs for axios request --- index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1904062..d60adaf 100644 --- a/index.js +++ b/index.js @@ -109,6 +109,8 @@ Mailchimp.prototype.patch = function (options, body, done) { } Mailchimp.prototype.request = function (options, done) { + console.log(JSON.stringify({ request_options: options })); + var mailchimp = this; var promise = new Promise(function(resolve, reject) { if (!options) { @@ -145,6 +147,18 @@ Mailchimp.prototype.request = function (options, done) { return; } + let axios_req = { + method : method, + url : mailchimp.__base_url + path, + data : body, + params : query, + headers : headers, + responseType: 'json', + } + + // omitted auth in log + console.log({ axios_req }); + axios({ method : method, url : mailchimp.__base_url + path, @@ -160,13 +174,15 @@ Mailchimp.prototype.request = function (options, done) { if (err) { var error = new Error(err); - console.log('Error', error.response); + console.log('Mailchimp Error', error.response); error.response = response; error.status = response ? response.status : undefined; reject(error) return; } + console.log('Mailchimp Response: ', response) + if (response.status < 200 || response.status > 299) { var error = Object.assign(new Error(response.data ? response.data : response.status), response.data || response) error.response = response;