Created
August 24, 2019 07:38
-
-
Save KaranPato/35752576bd30d15f1d0650fb0c4d4c9d to your computer and use it in GitHub Desktop.
MainService file.
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 { HttpHeaders, HttpClient } from '@angular/common/http'; | |
var reqHeader = new HttpHeaders({ 'Content-Type': 'application/json' }); | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class MainService { | |
//Add your API path here. | |
baseUrl = 'http://localhost:52100/api/Recepi/'; | |
constructor(private http: HttpClient) { } | |
GetRecipes() { | |
return this.http.get(this.baseUrl + "GetRecepies", { headers: reqHeader }); | |
} | |
GetRecipeById(Id) { | |
return this.http.post(this.baseUrl + "GetRecepiById", Id, { headers: reqHeader }) | |
} | |
AddRecepi(model) { | |
return this.http.post(this.baseUrl + "AddRecepi", model, { headers: reqHeader }); | |
} | |
DeleteRecepi(Id) { | |
return this.http.delete(this.baseUrl + "/" + Id, { headers: reqHeader }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment