Override Ngrx/data data service urls

370 Views Asked by At

I'm trying to use ngrx/data with my api. My api exposes resources under the format /resources for all requests instead of POST /resource (without 's'). Same for GET /resources/:id instead of /resource/:id as required by ngrx/data.

How can I force the data service to hit /resources for all requests? Thanks

1

There are 1 best solutions below

1
On

You might use an entity-metadata.ts files with following content:

const entityMetadata: EntityMetadataMap = {
  ressources: {}
};

const pluralNames = {
  ressources: 'ressources'
};

export const entityConfig = {
  entityMetadata,
  pluralNames,
};

In your module you need an import with:

EntityDataModule.forRoot(entityConfig)