Skip to content

Commit

Permalink
feat: set token
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Apr 15, 2020
1 parent f8f9799 commit dfcb038
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class PixivApp<CamelcaseKeys extends boolean = true> {
const { response } = axiosResponse.data
this.auth = response
this.refreshToken = axiosResponse.data.response.refresh_token
instance.defaults.headers.common.Authorization = `Bearer ${response.access_token}`
this.authToken = response.access_token
return this.camelcaseKeys
? camelcaseKeys(response, { deep: true })
: response
Expand All @@ -168,6 +168,11 @@ export default class PixivApp<CamelcaseKeys extends boolean = true> {
: (this.auth as authInfoType)
}

// eslint-disable-next-line class-methods-use-this
set authToken(accessToken: string) {
instance.defaults.headers.common.Authorization = `Bearer ${accessToken}`
}

hasNext(): boolean {
return Boolean(this.nextUrl)
}
Expand Down

0 comments on commit dfcb038

Please sign in to comment.