📜 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):
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Contributing Guidelines?
Are you willing to submit PR?
None
📜 Description
Hello,
With an
InAppnotification created with thedata(https://docs.novu.co/sdks/framework/typescript/steps/inbox) key inside, updating the read state (usingnotification.read()ornotification.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
👍 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>/readreturns the following payload:No
datakey exists and I think this is the root cause. The@novu/clientreads the.datakey fromresponse.json()to create a Notification which overlaps withNotification.datadefinition (https://docs.novu.co/sdks/framework/typescript/steps/inbox):novu/packages/client/src/http-client/http-client.ts
Line 83 in e900c02
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Contributing Guidelines?
Are you willing to submit PR?
None