Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API呼び出しにTokenが必要になったことに対応 #357

Merged
merged 2 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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