Skip to content

Instantly share code, notes, and snippets.

@KaranPato
Created August 24, 2019 07:38
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 KaranPato/35752576bd30d15f1d0650fb0c4d4c9d to your computer and use it in GitHub Desktop.
Save KaranPato/35752576bd30d15f1d0650fb0c4d4c9d to your computer and use it in GitHub Desktop.
MainService file.
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