Skip to content
Snippets Groups Projects
Commit 433c2f55 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

clean code

parent a1bcf881
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment