Skip to content

Commit

Permalink
fix: API呼び出しにTokenが必要になったことに対応 (#357)
Browse files Browse the repository at this point in the history
Co-authored-by: mnao305 <[email protected]>
  • Loading branch information
twinkfrag and mnao305 authored Feb 11, 2023
1 parent 86cac0e commit 47b6ace
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/content/modules/backnumberPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const fetchBacknumberData = async (): Promise<Backnumber> => {
const url = new URL((document.getElementsByClassName('tab-item tab-item-text active')[1] as HTMLAnchorElement).href)
const plan = url.searchParams.get('plan')
const month = url.searchParams.get('month')
const json = await ky.get(`https://fantia.jp/api/v1/fanclub/backnumbers/monthly_contents/plan/${plan}/month/${month}`).json<BacknumberResponse>()
const csrfToken = document.getElementsByName('csrf-token')[0].getAttribute('content') ?? ''
const json = await ky.get(`https://fantia.jp/api/v1/fanclub/backnumbers/monthly_contents/plan/${plan}/month/${month}`, { headers: { 'x-csrf-token': csrfToken } }).json<BacknumberResponse>()

return json.backnumber
}
3 changes: 2 additions & 1 deletion src/content/modules/postPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { blogDL } from './blog'

export const fetchPostData = async (): Promise<PostData> => {
const id = location.pathname.split('/posts/')[1]
const json = await ky.get(`https://fantia.jp/api/v1/posts/${id}`).json<PostDataResponse>()
const csrfToken = document.getElementsByName('csrf-token')[0].getAttribute('content') ?? ''
const json = await ky.get(`https://fantia.jp/api/v1/posts/${id}`, { headers: { 'x-csrf-token': csrfToken } }).json<PostDataResponse>()

return json.post
}
Expand Down

0 comments on commit 47b6ace

Please sign in to comment.