Angular HTTP
constructor(private http: HttpClient) { }
//GET ALL
GetAll(): Observable<any> {
return this.http.get(this.baseUrl + "/all");
}
//GET SINGLE
GetSingle(id: any): Observable<any> {
return this.http.get(this.baseUrl + "/single/" + id);
}
//PUT
Update(obj: Object) {
const data = JSON.stringify(obj);
return this.http.put(this.baseUrl, data, {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
});
}
//POST
Create(obj: Object) {
const data = JSON.stringify(obj);
return this.http.post(this.baseUrl, data, {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
});
}
//DELETE
Delete(obj: Object) {
const data = JSON.stringify(obj);
return this.http.delete(this.baseUrl + "/delete", data, {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
});
}
Lucky Lark