Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 10, 2019 23:59
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 parzibyte/b5a8e7b93760108cd3d332bb3310b21c to your computer and use it in GitHub Desktop.
Save parzibyte/b5a8e7b93760108cd3d332bb3310b21c to your computer and use it in GitHub Desktop.
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Persona } from "./persona";
@Injectable({
providedIn: "root"
})
export class PersonasService {
rutaApi = "https://rest-api-angular-php--parzibyte.repl.co";
constructor(private http: HttpClient) {}
obtener() {
return this.http.get(`${this.rutaApi}/obtenerPersonas.php`);
}
registrar(persona: Persona) {
return this.http.post(`${this.rutaApi}/registrarPersona.php`, persona);
}
actualizar(persona: Persona) {
return this.http.put(`${this.rutaApi}/actualizarPersona.php`, persona);
}
eliminar(id: string | number) {
return this.http.delete(`${this.rutaApi}/eliminarPersona.php?id=${id}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment