Search code examples
angularhttpserviceangular-ui-router

How to solve Service call using constant.service.ts file in Angular?


I'm not able to figure out what's the wrong with service call in angular. It works in other service call in same file. Can you please take a look and let me know what I'm missing?

Following code works fine --

client-agreement.service.ts

getClientAgreementById(id: number) {
    return this.http.get(this.constantService.getUrl(`${this.constantService.CLIENT_AGREEMENT}/${id}`));
  }

constant.service.ts

CLIENT_AGREEMENT = 'onboarding/client-agreement';

Following code does not work, what could be issue?

client-agreement.service.ts

removeClientAgreementFromJobs(id: number) {
    alert(this.constantService.getUrl(`${this.constantService.JOB_CLIENT_AGREEMENT}/${id}`));
    return this.http.delete(this.constantService.getUrl(`${this.constantService.JOB_CLIENT_AGREEMENT}/${id}`));
  }

constant.service.ts

JOB_CLIENT_AGREEMENT = 'api/JobClientagreements';

Solution

  • From wherever you are calling your service please subscribe then only you can see XHR request.

    this.clientAggrementService.removeClientAgreementFromJobs(130).subscribe(i=> { })

    wherever you are consuming your service please subscribe then you can see XHR request.