mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
🐛 bug: fix return null in get-all-blog.ts
:%s
This commit is contained in:
@@ -40,7 +40,8 @@ export default function getAllBlogsOperation({
|
||||
const { data } = await config.fetch<GetAllBlogsQuery>(query, {
|
||||
variables,
|
||||
})
|
||||
return {
|
||||
if(data){
|
||||
return {
|
||||
blogs: data?.blogs?.items?.map((val:BlogList)=>({
|
||||
id: val.id,
|
||||
title: val.translations[0]?.title,
|
||||
@@ -54,7 +55,11 @@ export default function getAllBlogsOperation({
|
||||
createdAt: val.createdAt
|
||||
})),
|
||||
totalItems: data?.blogs?.totalItems || null
|
||||
}
|
||||
}else{
|
||||
return {blogs:[]};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return getAllBlogs
|
||||
|
@@ -16,7 +16,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(
|
||||
<>
|
||||
|
Reference in New Issue
Block a user