|
1
|
"use server" |
|
2
|
|
|
3
|
import { CloudAnnouncement } from "types" |
|
4
|
|
|
5
|
export async function getAnnouncements(): Promise<CloudAnnouncement[]> { |
|
6
|
const response = await fetch( |
|
7
|
"https://api.prod.medusajs.cloud/v1/announcements?limit=3&offset=0&order=-published_at&type%5B0%5D=feature&type%5B1%5D=incident", |
|
8
|
{ |
|
9
|
// @ts-expect-error - next is not in the types for this package |
|
10
|
next: { |
|
11
|
revalidate: 3000, |
|
12
|
tags: ["announcements"], |
|
13
|
}, |
|
14
|
} |
|
15
|
) |
|
16
|
|
|
17
|
if (!response.ok) { |
|
18
|
throw new Error("Failed to fetch announcements") |
|
19
|
} |
|
20
|
|
|
21
|
const data = await response.json() |
|
22
|
// we'll merge them with the version announcement |
|
23
|
return data.announcements as CloudAnnouncement[] |
|
24
|
} |