Skip to content

🐛 Bug Report: @novu/js - Updating the read state of a Notification results in an empty instance #6631

@gtnsimon

Description

@gtnsimon

📜 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:

image

👎 Actual Behavior with Screenshots

This is bad Notification instance with no data inside:

image

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:

image

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?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions