k.niemeskern 2 years ago
parent
commit
07b9fc65a6
2 changed files with 6 additions and 9 deletions
  1. 4 3
      index.js
  2. 2 6
      lib/API.js

+ 4 - 3
index.js

@@ -16,7 +16,8 @@ let info = {
     tokens: null,
     expire: 0,
     active: true,
-    updateTime: 4000 // 25000 Api call / 24H
+    updateTime: 4000, // 25000 Api call / 24H,
+    error: 0
 }
 
 if (process.env.access_token) {
@@ -39,8 +40,8 @@ async function watchLinkedin(){
                 info.error = 0
             }
         }).catch( (err) => {
-            console.log("[DEBUG-LOG][watchLinkedin ERROR]", err);
-            info.error++
+            console.log("[DEBUG-LOG][watchLinkedin ERROR]", info.error, err);
+            info.error = info.error + 10
             if (info.error > 50) {
                 info.active = false
                 mail.notif(process.env.usermail, process.env.pswd, process.env.contact);

+ 2 - 6
lib/API.js

@@ -34,12 +34,8 @@ class API {
             };
 
             request.get({ url: url, headers: headers }, (err, response, body) => {
-                console.log(body);
-                if(err || !body.firstDegreeSize) {
-                    console.log("besoin de reject");
-                    return reject(err);
-                }
-                return resolve(JSON.parse(body));
+                if(err || !body.firstDegreeSize) reject(err);                
+                resolve(JSON.parse(body));
             });
         });
     }