useDirectusNotifications


Check out the Directus Notifications documentation.

getNotifications

Search for notifications, global search querys can be used

  • Arguments:
  • Returns: Array<T>
pages/notifications.vue
<script setup>const { getNotifications } = useDirectusNotifications();const router = useRouter();const notifications = await getNotifications({  params: {    filter: { subject: "Directus is great!" },  },});</script>

getNotificationByKey

Get notifications by primary id key.

pages/notifications.vue
<script setup>const { getNotificationByKey } = useDirectusNotifications();const notification = await getNotificationByKey({  id: "2",});</script>

createNotification

Create one notifications

Partial notification object can be provided

pages/notifications.vue
<script setup>const { createNotification } = useDirectusNotifications();await createNotification({  recipient: "13231234saf-24wasf",  subject: "Hey there!",});</script>

deleteNotifications

Delete one or multiple notifications, provide notification id's.

  • Arguments:
    • data: Array<string> | string;
  • Returns: Empty body
pages/notifications.vue
<script setup>const { deleteNotifications } = useDirectusNotifications();const notifications = ["15", "20", "22"];await deleteNotifications({ notifications });</script>