N
Novu15mo ago
empe

Removing all notifications

I have an objective of removing notifications sent to a specific subscriber. I'm currently testing the following method:
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
feedId: "feedOne",
});
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
feedId: "feedOne",
});
However, when I attempt to use this method, I receive an AxiosError with the message 'Request failed with status code 400.' It appears that the notifications I want to remove have _feedId set to null. Can you please provide guidance on how to successfully achieve my goal of removing these notifications?
1 Reply
empe
empeOP15mo ago
Solved: The removeAllNotifications method accepts an object with optional properties. One of these properties is feedId, which is the identifier for a specific feed of notifications. To remove notifications that don't have a specific _feedId set (i.e.,_feedId is null), you can simply omit the feedId property when making this call.
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
});
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
});
By not including the feedId parameter in the function call, you are instructing the system to remove all notifications regardless of their _feedId value.
Want results from more Discord servers?
Add your server