File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
packages/react-renderer-demo/src/components Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,17 @@ const getNotifications = () => {
40
40
const query = `?orderBy="expired-at"&startAt="${ new Date ( ) . toISOString ( ) } "&limitToFirst=10` ;
41
41
return fetch ( `https://data-driven-forms.firebaseio.com/notifications.json${ query } ` )
42
42
. then ( ( data ) => data . json ( ) )
43
- . then ( ( data ) => ( data ? data . filter ( Boolean ) . sort ( ( a , b ) => b [ 'created-at' ] . localeCompare ( a [ 'created-at' ] ) ) : [ ] ) ) ;
43
+ . then ( ( data ) => {
44
+ if ( typeof data !== 'object' ) {
45
+ return [ ] ;
46
+ }
47
+
48
+ if ( ! Array . isArray ( data ) ) {
49
+ data = Object . values ( data ) ;
50
+ }
51
+
52
+ return data . filter ( Boolean ) . sort ( ( a , b ) => b [ 'created-at' ] . localeCompare ( a [ 'created-at' ] ) ) ;
53
+ } ) ;
44
54
} ;
45
55
46
56
const createNotificationId = ( notification ) => `${ notification [ 'created-at' ] } -${ notification [ 'expired-at' ] } ` ;
You can’t perform that action at this time.
0 commit comments