From 433c2f5529a432d72f0be8e37f046625060bcbff Mon Sep 17 00:00:00 2001
From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com>
Date: Wed, 10 Jun 2020 13:31:02 +0200
Subject: [PATCH] clean code

---
 src/index.js | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/index.js b/src/index.js
index 94f75ac..15894fb 100644
--- a/src/index.js
+++ b/src/index.js
@@ -105,15 +105,11 @@ async function authenticate(login, password, baseUrl, apiAuthKey) {
     },
     json: true
   }
-  try {
-    const response = await rp(authRequest)
-    if (response.codeRetour === 100) {
-      return response
-    } else {
-      throw new Error(errors.LOGIN_FAILED)
-    }
-  } catch (error) {
-    throw error
+  const response = await rp(authRequest)
+  if (response.codeRetour === 100) {
+    return response
+  } else {
+    throw new Error(errors.LOGIN_FAILED)
   }
 }
 
@@ -136,10 +132,10 @@ async function getData(response, baseUrl, apiAuthKey) {
     json: true
   }
   try {
-    const response = await rp(dataRequest)
-    switch (response.codeRetour) {
+    const responseEgl = await rp(dataRequest)
+    switch (responseEgl.codeRetour) {
       case 100:
-        return format(response)
+        return format(responseEgl)
       case -2:
         throw new Error(errors.LOGIN_FAILED)
       case -1:
-- 
GitLab