🐛 bug: fix return null in get-all-blog.ts

:%s
This commit is contained in:
QuangNhan
2021-10-24 23:52:21 +07:00
parent 9d7d801c0b
commit 622d07b1a9
2 changed files with 6 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ export default function getAllBlogsOperation({
const { data } = await config.fetch<GetAllBlogsQuery>(query, {
variables,
})
if(data){
return {
blogs: data?.blogs?.items?.map((val:BlogList)=>({
id: val.id,
@@ -55,6 +56,10 @@ export default function getAllBlogsOperation({
})),
totalItems: data?.blogs?.totalItems || null
}
}else{
return {blogs:[]};
}
}
return getAllBlogs

View File

@@ -17,7 +17,6 @@ export default function BlogsPage({ blogs, featuredBlog, totalItems }:Props) {
let date = new Date(featuredBlog?.[0]?.createdAt ?? '' );
let fullDate = date.toLocaleString('en-us', { month: 'long' }) + " " + date.getDate()+","+date.getFullYear();
return(
<>
<BlogBreadCrumb />