Skip to content

Commit

Permalink
Merge pull request #36 from kokororin/feature/set-token
Browse files Browse the repository at this point in the history
Add a method to modify the internal token of Axios
  • Loading branch information
akameco authored Apr 15, 2020
2 parents f8f9799 + dfcb038 commit 3321838
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 3321838

Please sign in to comment.