-
-
Save nntndfrk/815ab9d4b2fcf3668bb522255819d171 to your computer and use it in GitHub Desktop.
Angular HTTP service
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 { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { Observable } from 'rxjs/Observable'; | |
@Injectable() | |
export class HttpService { | |
private host = 'http://59f4a79d4e78aa00120ef45c.mockapi.io'; | |
constructor(private http: HttpClient) { } | |
public get(route, params?): Observable<any> { | |
return this.http.get(`${this.host}/${route}`, params); | |
} | |
public post(route, data, params?): Observable<any> { | |
return this.http.post(`${this.host}/${route}`, data, params); | |
} | |
public put(route, data, params?): Observable<any> { | |
return this.http.put(`${this.host}/${route}`, data, params); | |
} | |
public delete(route, params?): Observable<any> { | |
return this.http.delete(`${this.host}/${route}`, params); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment