Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 11, 2020 02:47
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/d963da11a4f3876c6470944da27fefc0 to your computer and use it in GitHub Desktop.
Save parzibyte/d963da11a4f3876c6470944da27fefc0 to your computer and use it in GitHub Desktop.
import {Injectable} from '@angular/core';
import {Producto} from "./producto";
import {HttpService} from "./http.service";
@Injectable({
providedIn: 'root'
})
export class ProductosService {
constructor(private http: HttpService) {
}
public async eliminarProducto(idProducto) {
return await this.http.delete("/producto?id=".concat(idProducto));
}
public async agregarProducto(producto: Producto) {
return await this.http.post("/producto", producto);
}
/*
El formdata debe tener el id del producto
*/
public async agregarFotosDeProducto(fotos: FormData) {
return await this.http.formdata("/fotos_producto", fotos);
}
public async obtenerProductos() {
return await this.http.get("/productos");
}
public async obtenerProductosConFotos() {
return await this.http.get("/productos_con_fotos");
}
public async obtenerProductoConFotosPorId(idProducto) {
return await this.http.get("/producto?id=".concat(idProducto));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment