Skip to content

Commit

Permalink
docs(data): improve DefaultDataServiceConfig root parameter docs (#2075)
Browse files Browse the repository at this point in the history
Adds more details for the DefaultDataServiceConfig api docs and Entity Dataservice
doc page.  Specifically, added details and examples for providing a remote api to
the DefaultDataServiceConfig root parameter.  Current docs do not include this
information, and it this makes it clear how one would use a remote api, which is
a very common use case.

Closes #2071
  • Loading branch information
mxdmedia authored and brandonroberts committed Aug 22, 2019
1 parent 0385c35 commit ddab4cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion modules/data/src/dataservices/default-data-service-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { EntityHttpResourceUrls } from './http-url-generator';
* such as the `DefaultDataService<T>`.
*/
export abstract class DefaultDataServiceConfig {
/** root path of the web api (default: 'api') */
/**
* root path of the web api. may also include protocol, domain, and port
* for remote api, e.g.: `'https://api-domain.com:8000/api/v1'` (default: 'api')
*/
root?: string;
/**
* Known entity HttpResourceUrls.
Expand Down
4 changes: 2 additions & 2 deletions projects/ngrx.io/content/guide/data/entity-dataservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The shared configuration values are almost always specific to the application an
The NgRx Data library defines a `DefaultDataServiceConfig` for
conveying shared configuration to an entity collection data service.

The most important configuration property, `root`, returns the _root_ of every web api URL, the parts that come before the entity resource name.
The most important configuration property, `root`, returns the _root_ of every web api URL, the parts that come before the entity resource name. If you are using a remote API, this value can include the protocol, domain, port, and root path, such as `https://my-api-domain.com:8000/api/v1`.

For a `DefaultDataService<T>`, the default value is `'api'`, which results in URLs such as `api/heroes`.

Expand All @@ -121,7 +121,7 @@ First, create a custom configuration object of type `DefaultDataServiceConfig` :

```typescript
const defaultDataServiceConfig: DefaultDataServiceConfig = {
root: 'api',
root: 'https://my-api-domain.com:8000/api/v1',
timeout: 3000, // request timeout
}
```
Expand Down

0 comments on commit ddab4cd

Please sign in to comment.