Skip to content

Commit

Permalink
chore: fix old request ID bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Oct 19, 2023
1 parent 993f3de commit 0b277ee
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/pages/paywall/article/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,19 @@ export default function Article({ embed }: CustomPageProps) {
const router = useRouter();
const articleId = router.query.id;

const { data: fingerprintData } = useVisitorData({
const { getData: getVisitorData } = useVisitorData({
ignoreCache: true,
});

const { data: articleData } = useQuery<ArticleResponse>(
['GET_ARTICLE_QUERY', articleId],
() =>
fetch(`/api/paywall/article/${articleId}`, {
const { data: articleData } = useQuery<ArticleResponse>(['GET_ARTICLE_QUERY', articleId], async () => {
const { requestId, visitorId } = await getVisitorData();
return await (
await fetch(`/api/paywall/article/${articleId}`, {
method: 'POST',
body: JSON.stringify({
requestId: fingerprintData?.requestId,
visitorId: fingerprintData?.visitorId,
}),
}).then((res) => res.json()),
{
enabled: Boolean(fingerprintData),
},
);
body: JSON.stringify({ requestId, visitorId }),
})
).json();
});

const { article, remainingViews } = articleData?.data ?? {};
const returnUrl = `/paywall${embed ? '/embed' : ''}`;
Expand Down

0 comments on commit 0b277ee

Please sign in to comment.