strong-testimonials
/
admin
/
wpchill
/
apps
/
notification-system
/
query
/
useNotificationQuery.js
client.js
1 year ago
useNotificationDismiss.js
1 year ago
useNotificationQuery.js
1 year ago
useNotificationsDismiss.js
1 year ago
useNotificationQuery.js
16 lines
| 1 | import { useQuery } from '@tanstack/react-query'; |
| 2 | import apiFetch from '@wordpress/api-fetch'; |
| 3 | export const useNotificationQuery = () => { |
| 4 | return useQuery( { |
| 5 | queryKey: [ 'notifications' ], |
| 6 | queryFn: async () => { |
| 7 | const data = await apiFetch( { |
| 8 | path: `/wpchill/v1/notifications`, |
| 9 | method: 'GET', |
| 10 | } ); |
| 11 | return data; |
| 12 | }, |
| 13 | refetchInterval: ( query ) => query?.state?.fetchFailureCount < 5 ? 5000 : false, |
| 14 | } ); |
| 15 | }; |
| 16 |