Created
June 11, 2020 02:47
-
-
Save parzibyte/d963da11a4f3876c6470944da27fefc0 to your computer and use it in GitHub Desktop.
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 {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