Skip to content
Open
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
2 changes: 1 addition & 1 deletion node.js/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Internally the [timestamp](events#timestamp) is a JavaScript `Date` object, that

When returning [Media Data](../guides/providing-services#serving-media-data) from a custom `READ`, `action`, or `function` handler, content information can be configured as part of the handlers result object.

Ideally, handlers use [`req.reply`](events#req-reply-results), calling it with an instance of [stream.Readable](https://nodejs.org/api/stream.html#class-streamreadable). Include options to specify content disposition headers:
Ideally, handlers use [`req.reply`](events#req-reply), calling it with an instance of [stream.Readable](https://nodejs.org/api/stream.html#class-streamreadable). Include options to specify content disposition headers:

```js
srv.on('READ', 'Books', (req, next) => {
Expand Down
13 changes: 9 additions & 4 deletions node.js/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Additional note about OData: For requests that are part of a changeset, the even



Class `cds.Request` extends [`cds.Event`] with additional features to represent and deal with synchronous requests to services in [event handlers](./core-services#srv-handle-event), such as the [query](#query), additional [request parameters](#params), the [authenticated user](#user), and [methods to send responses](#req-reply-results).
Class `cds.Request` extends [`cds.Event`] with additional features to represent and deal with synchronous requests to services in [event handlers](./core-services#srv-handle-event), such as the [query](#query), additional [request parameters](#params), the [authenticated user](#user), and [methods to send responses](#req-reply).


[Router]: https://expressjs.com/en/4x/api.html#router
Expand Down Expand Up @@ -362,15 +362,19 @@ It's available for CRUD events and bound actions.



### req. reply (results) {.method}
### req. reply () {.method}
Copy link
Contributor

@sjvans sjvans Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### req. reply () {.method}
### req. reply (results) {.method}

i'd leave this as is. btw, formatting is inconsistent with req. error(), etc. (no space before ())


```tsx
function req.reply (
results : object | object[] | string | number | true | false | null
results : object | object[] | string | number | true | false | null,
options? : {
mimetype? : string
filename? : string
}
)
```

Stores the given argument in `req.results`, which is subsequently sent back to the client, rendered in a protocol-specific way.
Stores the first argument in `req.results`, which is subsequently sent back to the client, rendered in a protocol-specific way.

```js
this.on ('READ', Books, req => {
Expand All @@ -392,6 +396,7 @@ this.on ('READ', Books, req => {
})
```

The optional second argument `options` can be used to specify content disposition headers in case of [custom streaming (beta)](best-practices#custom-streaming-beta).

### req. reject ({ ... }) {.method #req-reject}

Expand Down