Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit ba37569

Browse files
committed
move reddit follower fetch to client
1 parent 760f157 commit ba37569

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

src/pages/api/social-data.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,12 @@ export default async function handler(
2323
},
2424
}
2525

26-
const redditResponse = await fetch(
27-
'https://www.reddit.com/r/everipedia/about.json',
28-
{
29-
headers: {
30-
'User-Agent': 'IQ-UI/1.0',
31-
},
32-
},
33-
).then((res) => {
34-
if (!res.ok) throw new Error('Reddit API failed')
35-
return res.json()
36-
})
37-
const twitterResponse = await fetch(url, options).then((res) => {
38-
if (!res.ok) throw new Error('Twitter API failed')
39-
return res.json()
40-
})
26+
const twitterResponse = await fetch(url, options)
4127

4228
const { followers_count: twitterFollowers } = await twitterResponse.json()
43-
const redditData = await redditResponse.json()
29+
4430
const data = {
4531
twitterFollowers,
46-
redditFollowers: redditData.data.subscribers,
4732
}
4833

4934
setCacheHeaders(res)

src/utils/stats-data.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,16 @@ const getEpData = async () => {
329329

330330
const getSocialData = async () => {
331331
try {
332+
const redditResponse = await fetch(
333+
'https://www.reddit.com/r/everipedia/about.json',
334+
)
332335
const twitterResponse = await fetch('/api/social-data')
333-
const { twitterFollowers, redditFollowers } = await twitterResponse.json()
336+
const { twitterFollowers } = await twitterResponse.json()
337+
const redditData = await redditResponse.json()
334338
return {
335339
social: {
336340
twitter: twitterFollowers,
337-
reddit: redditFollowers,
341+
reddit: redditData.data.subscribers,
338342
},
339343
}
340344
} catch (err) {

0 commit comments

Comments
 (0)