fix(frontend/Blog) fix compatibility with new backend

This commit is contained in:
lumither committed 2024-05-04 00:51:32 +08:00
1 parent b17e8a19eb
commit a9ba365bac
3 files changed
+42 -46

No files matched your search

+19 -18
View File
@@ -4,26 +4,27 @@ import BlogPostCard from '@/app/blog/BlogPostCard';
async function Blog() {
const res = await fetch_posts_list();
if (!res.ok) {
console.log(res.error);
return;
try {
const res = await fetch_posts_list();
let posts = res['posts'];
return (
// blog list
<ul className={ 'flex flex-col items-center w-full max-w-[1024px]' }>
{ posts.map((post: JSON, key: React.Key | null | undefined) => (
<li key={ key } className={ 'my-3.5 mx-7 w-[80%]' }>
<BlogPostCard post={ post } />
</li>)
) }
</ul>
);
} catch (e: any) {
return (
<>
{ e.toString() }
</>
);
}
const posts = res.value;
console.log(posts);
return (
// blog list
<ul className={ 'flex flex-col items-center w-full max-w-[1024px]' }>
{ posts.map((post, key) => (
<li key={ key } className={ 'my-3.5 mx-7 w-[80%]' }>
<BlogPostCard post={ post } />
</li>)
) }
</ul>
);
}
export default Blog;