Created
December 16, 2019 04:07
-
-
Save IntegerMan/7c98aec000b167843627620f64fdbc03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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