mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +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, {
|
const { data } = await config.fetch<GetAllBlogsQuery>(query, {
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
return {
|
if(data){
|
||||||
|
return {
|
||||||
blogs: data?.blogs?.items?.map((val:BlogList)=>({
|
blogs: data?.blogs?.items?.map((val:BlogList)=>({
|
||||||
id: val.id,
|
id: val.id,
|
||||||
title: val.translations[0]?.title,
|
title: val.translations[0]?.title,
|
||||||
@@ -54,7 +55,11 @@ export default function getAllBlogsOperation({
|
|||||||
createdAt: val.createdAt
|
createdAt: val.createdAt
|
||||||
})),
|
})),
|
||||||
totalItems: data?.blogs?.totalItems || null
|
totalItems: data?.blogs?.totalItems || null
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return {blogs:[]};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAllBlogs
|
return getAllBlogs
|
||||||
|
@@ -16,7 +16,6 @@ export default function BlogsPage({ blogs, featuredBlog, totalItems }:Props) {
|
|||||||
|
|
||||||
let date = new Date(featuredBlog?.[0]?.createdAt ?? '' );
|
let date = new Date(featuredBlog?.[0]?.createdAt ?? '' );
|
||||||
let fullDate = date.toLocaleString('en-us', { month: 'long' }) + " " + date.getDate()+","+date.getFullYear();
|
let fullDate = date.toLocaleString('en-us', { month: 'long' }) + " " + date.getDate()+","+date.getFullYear();
|
||||||
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
|
Reference in New Issue
Block a user