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 = () => {
4040 const query = `?orderBy="expired-at"&startAt="${ new Date ( ) . toISOString ( ) } "&limitToFirst=10` ;
4141 return fetch ( `https://data-driven-forms.firebaseio.com/notifications.json${ query } ` )
4242 . 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+ } ) ;
4454} ;
4555
4656const createNotificationId = ( notification ) => `${ notification [ 'created-at' ] } -${ notification [ 'expired-at' ] } ` ;
You can’t perform that action at this time.
0 commit comments