Bläddra i källkod

Adding debug logs

bodicsek 6 år sedan
förälder
incheckning
90b90a6d32
1 ändrade filer med 13 tillägg och 7 borttagningar
  1. 13 7
      app.js

+ 13 - 7
app.js

@@ -64,16 +64,20 @@ function sign(request, options) {
 
 // generates a function to handle the https.request response object
 function handleRequest(callback) {
-
     return function (response) {
+        console.log('!!! statusCode:', response.statusCode);
+        console.log('!!! headers:', response.headers);
+
         var responseBody = "";
 
         response.on('data', function (chunk) {
+            console.log('!!! data:', { chunk });
             responseBody += chunk;
         });
 
         response.on('end', function () {
-            callback(JSON.parse(responseBody));
+            console.log('!!! end:', { responseBody });
+            callback(responseBody ? JSON.parse(responseBody) : "");
         });
     }
 }
@@ -156,10 +160,12 @@ function healthCheck(callback) {
 //     console.log(data);
 // });
 
-getInvoices(function (data) {
-    console.log(data);
+healthCheck(function (data) {
+    console.log("+++ healthCheck");
+    console.log("+++", data);
 });
 
-// healthCheck(function (data) {
-//     console.log(data);
-// });
+getInvoices(function (data) {
+    console.log("+++ getInvoices");
+    console.log("+++", data);
+});