diff --git a/index.js b/index.js index 1e6557041d6cbcec19fdd0e80ff8041a82fb1274..b2762bab1b30f91f518d9cc73c1e64eab24c3bd3 100644 --- a/index.js +++ b/index.js @@ -215,11 +215,10 @@ async function authenticate(login, password, baseUrl, apiAuthKey) { } try { const resp = await axios(authRequest) - const data = resp.data - if (data.codeRetour === 100) { - return data + if (resp.data.codeRetour === 100) { + return resp.data } else { - Sentry.captureException(JSON.stringify(data)) + Sentry.captureException(JSON.stringify(resp.data)) throw new Error() } } catch (error) { @@ -247,15 +246,13 @@ async function getData(response, baseUrl, apiAuthKey) { try { // Sort data by date const resp = await axios(dataRequest) - const data = await resp.data - log('debug', data) - data.resultatRetour.sort(function(a, b) { + resp.data.resultatRetour.sort(function(a, b) { return new Date(a.DateReleve) - new Date(b.DateReleve) }) - switch (data.codeRetour) { + switch (resp.data.codeRetour) { case 100: - return format(data) + return format(resp.data) case -2: throw errors.LOGIN_FAILED case -1: