feat: fix async request

This commit is contained in:
Tim
2025-08-05 15:21:14 +08:00
parent dc73a74e1c
commit 1ed76f7687

View File

@@ -336,9 +336,11 @@ export default {
} }
const fetchTimeline = async () => { const fetchTimeline = async () => {
const postsRes = await fetch(`${API_BASE_URL}/api/users/${username}/posts?limit=50`) const [postsRes, repliesRes, tagsRes] = await Promise.all([
const repliesRes = await fetch(`${API_BASE_URL}/api/users/${username}/replies?limit=50`) fetch(`${API_BASE_URL}/api/users/${username}/posts?limit=50`),
const tagsRes = await fetch(`${API_BASE_URL}/api/users/${username}/tags?limit=50`) fetch(`${API_BASE_URL}/api/users/${username}/replies?limit=50`),
fetch(`${API_BASE_URL}/api/users/${username}/tags?limit=50`)
])
const posts = postsRes.ok ? await postsRes.json() : [] const posts = postsRes.ok ? await postsRes.json() : []
const replies = repliesRes.ok ? await repliesRes.json() : [] const replies = repliesRes.ok ? await repliesRes.json() : []
const tags = tagsRes.ok ? await tagsRes.json() : [] const tags = tagsRes.ok ? await tagsRes.json() : []
@@ -367,8 +369,10 @@ export default {
} }
const fetchFollowUsers = async () => { const fetchFollowUsers = async () => {
const followerRes = await fetch(`${API_BASE_URL}/api/users/${username}/followers`) const [followerRes, followingRes] = await Promise.all([
const followingRes = await fetch(`${API_BASE_URL}/api/users/${username}/following`) fetch(`${API_BASE_URL}/api/users/${username}/followers`),
fetch(`${API_BASE_URL}/api/users/${username}/following`)
])
followers.value = followerRes.ok ? await followerRes.json() : [] followers.value = followerRes.ok ? await followerRes.json() : []
followings.value = followingRes.ok ? await followingRes.json() : [] followings.value = followingRes.ok ? await followingRes.json() : []
} }