Skip to content

Instantly share code, notes, and snippets.

@RayLuxembourg
Last active August 19, 2018 14:46
Show Gist options
  • Save RayLuxembourg/69586474c3c006eb3a5e78bed2a69e94 to your computer and use it in GitHub Desktop.
Save RayLuxembourg/69586474c3c006eb3a5e78bed2a69e94 to your computer and use it in GitHub Desktop.
Api Service
//src/common/services/api.service.ts
@Injectable({ providedIn: 'root' })
export class ApiService {
monitor = "/monitor";
analytics = "/analytics";
api = "/api"
constructor(private httpClient: HttpClient) { }
apiCallExample() {
return this.httpClient.get(`${this.api}/products`);
}
monitorCallExample(someInfo = {}) {
return this.httpClient.put(`${this.monitor}/23874`, someInfo);
}
analyticsCallExample(event = {}) {
return this.httpClient.post(`${this.analytics}/expend`, event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment