You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
// taken from the Stackblitz repro for quick reviewimport{Novu}from'@novu/js';constnovu=newNovu({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',});constnotifications=awaitnovu.notifications.list();const[notificationToUpdate]=notifications.data.notifications??[];constupdatedNotification=awaitnotificationToUpdate.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):
@gtnsimon i want to work on this issue can you please assign me this issue
gtnsimon
changed the title
🐛 Bug Report: @novu/js - Updating the read state of an Notification is resulting in an empty instance
🐛 Bug Report: @novu/js - Updating the read state of a Notification results in an empty instance
Oct 7, 2024
📜 Description
Hello,
With an
InApp
notification 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>/read
returns the following payload:No
data
key exists and I think this is the root cause. The@novu/client
reads the.data
key fromresponse.json()
to create a Notification which overlaps withNotification.data
definition (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
The text was updated successfully, but these errors were encountered: