Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Apr 20, 2024
1 parent 71b6c7b commit cdef59e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions ariston/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ export default class AristonAPI {
return this.#api.request(response.config)
}
}
if (response.config.jar) {
this.#setCookieExpiration(response.config.jar)
}
this.#setCookieExpiration(response.config.jar)
return response
}

Expand All @@ -185,20 +183,22 @@ export default class AristonAPI {
)
}

#setCookieExpiration(jar: CookieJar): void {
jar.getCookies(DOMAIN, (error, cookies): void => {
if (error) {
this.#logger.error(error.message)
return
}
const aspNetCookie = cookies.find(
(cookie) => cookie.key === '.AspNet.ApplicationCookie',
)
if (aspNetCookie) {
const expiresDate = new Date(String(aspNetCookie.expires))
this.#settingManager.set('expires', expiresDate.toISOString())
}
})
#setCookieExpiration(jar?: CookieJar): void {
if (jar) {
jar.getCookies(DOMAIN, (error, cookies): void => {
if (error) {
this.#logger.error(error.message)
return
}
const aspNetCookie = cookies.find(
(cookie) => cookie.key === '.AspNet.ApplicationCookie',
)
if (aspNetCookie) {
const expiresDate = new Date(String(aspNetCookie.expires))
this.#settingManager.set('expires', expiresDate.toISOString())
}
})
}
}

#setupAxiosInterceptors(): void {
Expand Down

0 comments on commit cdef59e

Please sign in to comment.