Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.