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
6 changes: 3 additions & 3 deletions node.js/core-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ 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
- `path` can be an arbitrary URL, starting with a leading `'/'`
- `method` can be an HTTP method, or a name of a custom action or function
- `path` can be an arbitrary URL, starting with a leading `'/'`, it is passed to a service without any modification as a string

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 unmodified to a service. Omitting the leading slash, or passing a reflected entity definition instead, constructs *bound* [`cds.ql` query objects](cds-ql), equivalent to [CRUD-style API](#crud-style-api):

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