Search code examples
sap-commerce-cloudspartacus-storefront

How to add new occ endpoints paramater to get url?


I am referencing defaultOccProductConfig and want to add new endpoint to get url dynamicly.

For example;

productReviews: 'products/${productCode}/reviews', // this is existing endpoint
productManipulation: 'products/${productCode}/manipulation' // this is what i want to add

I am getting an error when add this endpoint after import module. How can i override my new endpoint?


Solution

  • In your nodule (i.e. app module) please provide your custom config chunk by importing ConfigModule.withConfig(). For example:

    @NgModule({
      imports: [
        /* ... */
        ConfigModule.withConfig({
          backend: {
            occ: {
              endpoints: {
                productManipulation: 'products/${productCode}/manipulation' // this is what i want to add
              }
            }
          }
        })
        /* ... */
      ]
    })
    export class AppModule {};
    

    For more, see docs: