diff --git a/pages/dashboards/[[...location]].js b/pages/dashboards/[[...location]].js index 573783f4e1..f9fa9cd0ee 100644 --- a/pages/dashboards/[[...location]].js +++ b/pages/dashboards/[[...location]].js @@ -108,7 +108,7 @@ export const getServerSideProps = async ({ params, query, req }) => { } let countryData = await getCategorisedCountries(true); - const notifications = await getPublishedNotifications({}); + const notifications = await getPublishedNotifications(); if (!type || type === 'global') { // get global data diff --git a/pages/grants-and-fellowships/[section].js b/pages/grants-and-fellowships/[section].js index 4be08a625c..1acd668243 100644 --- a/pages/grants-and-fellowships/[section].js +++ b/pages/grants-and-fellowships/[section].js @@ -28,7 +28,7 @@ export const getServerSideProps = async ({ query }) => { }; } - const notifications = await getPublishedNotifications({}); + const notifications = await getPublishedNotifications(); if (query?.section === 'projects') { const pageTexts = await getSGFPage(); diff --git a/pages/index.js b/pages/index.js index 759ce3004f..152912b3de 100644 --- a/pages/index.js +++ b/pages/index.js @@ -24,7 +24,7 @@ const HomePage = (props) => ( export const getStaticProps = async () => { const newsArticles = await getNewsArticles(); - const notifications = await getPublishedNotifications({}); + const notifications = await getPublishedNotifications(); return { props: { diff --git a/pages/map/[[...location]].js b/pages/map/[[...location]].js index 6daf9f1869..367b2590aa 100644 --- a/pages/map/[[...location]].js +++ b/pages/map/[[...location]].js @@ -32,7 +32,7 @@ const ALLOWED_TYPES = ['global', 'country', 'wdpa', 'use', 'geostore', 'aoi']; export const getServerSideProps = async ({ req, params }) => { const [type] = params?.location || []; let userToken = null; - const notifications = await getPublishedNotifications({}); + const notifications = await getPublishedNotifications(); try { userToken = parse(req.headers.cookie)['gfw-token']; diff --git a/pages/my-gfw.js b/pages/my-gfw.js index d48012ca74..3bb50a2481 100644 --- a/pages/my-gfw.js +++ b/pages/my-gfw.js @@ -17,7 +17,7 @@ const MyGfwPage = (props) => ( ); export const getStaticProps = async () => { - const notifications = await getPublishedNotifications({}); + const notifications = await getPublishedNotifications(); return { props: { diff --git a/services/__tests__/notifications.spec.js b/services/__tests__/notifications.spec.js index 6633b19485..f24740d5b1 100644 --- a/services/__tests__/notifications.spec.js +++ b/services/__tests__/notifications.spec.js @@ -34,7 +34,7 @@ describe.skip('getPublishedNotifications', () => { axios.get.mockResolvedValueOnce(response); - const result = await getPublishedNotifications({}); + const result = await getPublishedNotifications(); expect(result).toEqual(expectedResult); }); @@ -46,7 +46,7 @@ describe.skip('getPublishedNotifications', () => { axios.get.mockRejectedValueOnce(new Error(message)); - const result = await getPublishedNotifications({}); + const result = await getPublishedNotifications(); expect(result).toBe(null); }); diff --git a/services/notifications.js b/services/notifications.js index 2e15c86488..5d7b49d9a1 100644 --- a/services/notifications.js +++ b/services/notifications.js @@ -33,15 +33,11 @@ apiFetch.setFetchHandler(async (options) => { }); }); -export const getPublishedNotifications = async ({ cancelToken }) => { +export const getPublishedNotifications = async () => { try { - const notificationsData = await apiFetch({ - url: `${process.env.NEXT_PUBLIC_WORDPRESS_URL}/wp/v2/notice?per_page=100&page=1&orderby=date&order=desc`, - params: { - _embed: true, - }, - cancelToken, - }); + const notificationsData = await axios( + `${process.env.NEXT_PUBLIC_WORDPRESS_URL}/wp/v2/notice?per_page=100&page=1&orderby=date&order=desc` + ); return notificationsData?.data.map((item) => mapResponseToNotification(item)