Skip to content

Commit

Permalink
added logs for axios request
Browse files Browse the repository at this point in the history
  • Loading branch information
krcummings1 committed Apr 22, 2024
1 parent 3bee655 commit 2bf05e6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 2bf05e6

Please sign in to comment.