This repository was archived by the owner on Feb 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,9 @@ export class AppHome {
7575
7676 async getFeaturedPost ( ) {
7777 this . featuredIsLoading = true ;
78- this . featuredPost = await Fetch . fetchOneBlogPost ( ) ;
79- this . featuredPost1 = await Fetch . fetchOneBlogPost ( 1 ) ;
78+ const homePosts = await Fetch . fetchHomeBlogPosts ( ) ;
79+ this . featuredPost = homePosts . first ;
80+ this . featuredPost1 = homePosts . second ;
8081 this . featuredIsLoading = false ;
8182 }
8283
Original file line number Diff line number Diff line change @@ -19,6 +19,24 @@ export async function fetchOneBlogPost(postNum: number = 0) {
1919 } ) ;
2020}
2121
22+ export async function fetchHomeBlogPosts ( ) {
23+ return await fetch ( `${ urlPosts } ?${ authToken } &page_size=2` )
24+ . then ( res => res . json ( ) )
25+ . then ( resp => {
26+ if ( resp . data . length > 1 ) {
27+ return {
28+ first : resp . data [ 0 ] ,
29+ second : resp . data [ 1 ] ,
30+ } ;
31+ }
32+ return null ;
33+ } )
34+ . catch ( resp => {
35+ console . log ( resp ) ;
36+ return null ;
37+ } ) ;
38+ }
39+
2240export async function fetchBlogPosts ( ) {
2341 return await fetch ( `${ urlPosts } ?${ authToken } ` )
2442 . then ( res => res . json ( ) )
You can’t perform that action at this time.
0 commit comments