Commit 17b68461c5e5af8e00608f722c0227d3918d9f5e
1 parent
a0a61a274b
Exists in
master
and in
1 other branch
Creado servicio para hacer get de promociones.
Showing
1 changed file
with
10 additions
and
3 deletions
Show diff stats
src/app/services/producto.service.ts
| 1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core'; |
| 2 | import { HttpClient } from '@angular/common/http'; | 2 | import { HttpClient } from '@angular/common/http'; |
| 3 | import { Observable } from 'rxjs'; | 3 | import { Observable } from 'rxjs'; |
| 4 | import { appSettings } from 'src/etc/AppSettings'; | 4 | import { appSettings } from 'src/etc/AppSettings'; |
| 5 | import { Producto } from '../wrappers/producto'; | 5 | import { Producto } from '../wrappers/producto'; |
| 6 | 6 | ||
| 7 | @Injectable({ | 7 | @Injectable({ |
| 8 | providedIn: 'root' | 8 | providedIn: 'root' |
| 9 | }) | 9 | }) |
| 10 | export class ProductoService { | 10 | export class ProductoService { |
| 11 | 11 | ||
| 12 | productos : Producto[] = []; | 12 | productos: Producto[] = []; |
| 13 | productoAcargar: Producto; | ||
| 13 | 14 | ||
| 14 | constructor(private http: HttpClient) { } | 15 | constructor(private http: HttpClient) { } |
| 15 | 16 | ||
| 16 | getAll(): Observable<any> { | 17 | getAll(): Observable<any> { |
| 17 | 18 | ||
| 18 | return this.http.get(`${appSettings.apiUrl}/articulos`); | 19 | return this.http.get(`${appSettings.apiUrl}/articulos`); |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | setProductos(producto : Producto){ | 22 | setProductos(producto: Producto) { |
| 22 | 23 | ||
| 23 | this.productos.push(producto); | 24 | this.productos.push(producto); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | getPromocion(sector, codigo): Observable<any> { | ||
| 28 | // var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; | ||
| 29 | var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${3}/${25}`; | ||
| 30 | return this.http.get(url); | ||
| 31 | } | ||
| 32 | |||
| 26 | } | 33 | } |
| 27 | 34 |