Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]

### Added

- Log full response body and headers when the `notifications` logger is enabled at debug level.
- Return the full HTTP response from the REST notification handler.
Note: With outbox enabled (default), the application's `await notify()` resolves when
the message is queued; the return value is only available when `outbox: false`.

## Version 0.3.0

### Added
Expand Down
11 changes: 9 additions & 2 deletions srv/notifyToRest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ module.exports = exports = class NotifyToRest extends NotificationService {
LOG._info && LOG.info(
`Sending notification of key: ${notificationData.NotificationTypeKey} and version: ${notificationData.NotificationTypeVersion}`
);
await executeHttpRequest(notificationDestination, {
const response = await executeHttpRequest(notificationDestination, {
url: `${NOTIFICATIONS_API_ENDPOINT}/Notifications`,
method: "post",
data: notificationData,
headers: csrfHeaders,
headers: { ...csrfHeaders, Accept: "application/json" },
});
if (LOG._debug) {
LOG.debug("Notification sent", {
body: response?.data,
headers: response?.headers,
});
}
return response;
} catch (err) {
const message = err.response.data?.error?.message?.value ?? err.response.message;
const error = new cds.error(message);
Expand Down