Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.js: leading slash in the path argument of rest-style api #460

Merged
merged 10 commits into from
Oct 10, 2023
4 changes: 2 additions & 2 deletions node.js/core-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ return : result of this.dispatch(req)
Use this method to send synchronous requests to a service for execution.

- `method` can be a HTTP method, or a name of a custom action or function
etimr marked this conversation as resolved.
Show resolved Hide resolved
- `path` can be an arbitrary URL, starting with a leading `'/'`
- `path` can be an arbitrary URL, starting with a leading `'/'`, it is passed to a service without any modification as a string.
etimr marked this conversation as resolved.
Show resolved Hide resolved

Examples:

Expand Down Expand Up @@ -1125,7 +1125,7 @@ srv.patch('/Books',...) --> srv.send('PATCH','/Books',...)
srv.delete('/Books',...) --> srv.send('DELETE','/Books',...)
```

You can also use them as REST-style variants to run queries by omitting the leading slash in the `path` argument, or by passing a reflected entity definition instead. In that case they start constructing *bound* [`cds.ql` query objects](cds-ql), as their [CRUD-style counterparts](#crud-style-api):
Leading slash in the `path` argument results in the same behaviour as in `srv.send()`: `path` is sent to a service unmodified. Omitting the leading slash or passing a reflected entity definition instead, leads to construction of *bound* [`cds.ql` query objects](cds-ql), equivalent to [CRUD-style API](#crud-style-api):
etimr marked this conversation as resolved.
Show resolved Hide resolved

```js
await srv.get(Books,201)
Expand Down