Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created December 16, 2019 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/7c98aec000b167843627620f64fdbc03 to your computer and use it in GitHub Desktop.
Save IntegerMan/7c98aec000b167843627620f64fdbc03 to your computer and use it in GitHub Desktop.
import {HttpClient} from '@angular/common/http';
import {Inject, Injectable} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MathService {
constructor(private http: HttpClient, @Inject('BASE_URL') private baseUrl: string) { }
add(x: string, y: string): Promise<string> {
return this.http.get<string>(`${this.baseUrl}calculator/add/${x}/${y}`).toPromise();
}
subtract(x: string, y: string): Promise<string> {
return this.http.get<string>(`${this.baseUrl}calculator/subtract/${x}/${y}`).toPromise();
}
multiply(x: string, y: string): Promise<string> {
return this.http.get<string>(`${this.baseUrl}calclator/multiply/${x}/${y}`).toPromise();
}
divide(x: string, y: string): Promise<string> {
return this.http.get<string>(`${this.baseUrl}calculator/divide/${x}/${y}`).toPromise();
}
power(x: string, y: string): Promise<string> {
return this.http.get<string>(`${this.baseUrl}calculator/power/${x}/${y}`).toPromise();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment