File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ export class TrssDataList {
33
33
< ul >
34
34
{ this . listData . items . slice ( 0 , this . limit ) . map ( ( item : any = { } ) => (
35
35
< li >
36
- < h3 class = "header" > < a href = { item . url } > { this . getEncodedText ( item . title ) } </ a > </ h3 >
36
+ < h3 class = "header" >
37
+ < a href = { item . url } > { this . getEncodedText ( item . title ) } </ a >
38
+ </ h3 >
37
39
< span class = "meta" > { friendly_date ( item . date_published ) } </ span >
38
40
{ item . summary && this . teaser ? < p class = "description" > { this . getEncodedText ( item . summary ) } </ p > : '' }
39
41
</ li >
@@ -46,8 +48,13 @@ export class TrssDataList {
46
48
listData = { items : [ ] } ;
47
49
48
50
async componentWillRender ( ) {
49
- let getApi = await fetch ( this . source , { method : 'GET' , headers : { 'Content-Type' : 'application/json' } } ) ;
50
- this . listData = await getApi . json ( ) ;
51
+ if ( ! sessionStorage . getItem ( 'trssFetchedData' ) || sessionStorage . getItem ( 'trssFetchedData' ) === '{}' ) {
52
+ let getApi = await fetch ( this . source , { method : 'GET' , headers : { 'Content-Type' : 'application/json' } } ) ;
53
+ sessionStorage . setItem ( 'trssFetchedData' , JSON . stringify ( await getApi . json ( ) ) ) ;
54
+ this . listData = JSON . parse ( sessionStorage . getItem ( 'trssFetchedData' ) ) ;
55
+ } else {
56
+ this . listData = JSON . parse ( sessionStorage . getItem ( 'trssFetchedData' ) ) ;
57
+ }
51
58
}
52
59
53
60
private getEncodedText ( text ) : string {
You can’t perform that action at this time.
0 commit comments