Merge pull request #10 from nightbug-xx/z1auo3-codex/친구정보-출력-문제-수정

Fix friend list fetching
This commit is contained in:
nightbug-xx 2025-06-10 10:24:37 +09:00 committed by GitHub
commit 2a18572e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,6 @@ interface Friend {
}
export default function FriendListPage() {
const [friendIds, setFriendIds] = useState<number[]>([])
const [friends, setFriends] = useState<Friend[]>([])
const [showDialog, setShowDialog] = useState(false)
const navigate = useNavigate()
@ -17,13 +16,8 @@ export default function FriendListPage() {
useEffect(() => {
const fetchFriends = async () => {
try {
const ids: number[] = await api.get('/friends/list').then(res => res.data)
setFriendIds(ids)
const friendInfos = await Promise.all(
ids.map(id => api.get(`/users/${id}`).then(res => res.data))
)
setFriends(friendInfos)
const res = await api.get('/friends/list')
setFriends(res.data)
} catch (e) {
console.error('친구 목록 불러오기 실패', e)
}