-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
📜 Description
Hello,
With an InApp notification created with the data (https://docs.novu.co/sdks/framework/typescript/steps/inbox) key inside, updating the read state (using notification.read() or notification.unread()) results to an empty Notification instance.
👟 Reproduction steps
Front-end reproduction (with samples Workflows to reproduce the issue): https://stackblitz.com/edit/sb1-gov1vt?file=main.js
// taken from the Stackblitz repro for quick review
import { Novu } from '@novu/js';
const novu = new Novu({
subscriberId: import.meta.env.VITE_NOVU_SUB_ID,
applicationIdentifier: import.meta.env.VITE_NOVU_APP_ID,
backendUrl: 'https://api.novu.co',
socketUrl: 'https://ws.novu.co',
});
const notifications = await novu.notifications.list();
const [notificationToUpdate] = notifications.data.notifications ?? [];
const updatedNotification = await notificationToUpdate.read();
console.log('updatedNotification', updatedNotification);👍 Expected behavior
This is a valid Notification instance with data inside:
👎 Actual Behavior with Screenshots
This is bad Notification instance with no data inside:
Novu version
Novu SaaS
npm version
NA
node version
NA
📃 Provide any additional context for the Bug.
The Novu API response when calling https://api.novu.co/v1/inbox/notifications/<NOTIFICATION_ID>/read returns the following payload:
No data key exists and I think this is the root cause. The @novu/client reads the .data key from response.json() to create a Notification which overlaps with Notification.data definition (https://docs.novu.co/sdks/framework/typescript/steps/inbox):
| return data.data; |
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find a similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit PR?
None