Last active
March 2, 2018 16:57
-
-
Save jota12x/591ca1072f75012ea7b62c0e2d7b66ef 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 { Http, Response,RequestOptions,Headers,RequestMethod} from '@angular/http'; | |
import { Observable } from 'rxjs/Rx'; | |
import 'rxjs/add/operator/map'; | |
import * as _ from "lodash"; | |
import {OauthUtility} from './oauth'; | |
// Object Type | |
import { Product } from './data/product'; | |
import {MagentoProduct} from './data/magentoProduct'; | |
import { Logo } from './data/logo'; | |
import { Category } from './data/category'; | |
import { Size } from './data/size'; | |
import { Color } from './data/color'; | |
import {environment} from '../../../environments/environment'; | |
//import {CordovaOauthMagento} from 'ng2-oauth-magento/core'; | |
@Injectable() | |
export class productService { | |
private base: string = './assets/json/'; | |
private baseURL: string = 'http://159.89.46.186/rest/default/V1/categories'; | |
private URLProductos: string = 'http://159.89.46.186/rest/default/V1/products?searchCriteria%5BpageSize%5D=10'; | |
private headers = new Headers(); | |
constructor(private http:Http){ | |
} | |
// Get Products | |
getProduct(): Observable<Product[]>{ | |
const options = new RequestOptions({headers: this.headers,method:'GET'}); | |
//console.log(options); | |
return this.http.get(this.base + 'product.json',options) | |
.map((res:Response) => res.json()); | |
} | |
appendHeaders(){ | |
let authString= 'Bearer hfwnkowu3elsommq10hbgfs2a46fjgek'; | |
this.headers.append('Authorization', authString); | |
this.headers.append('Content-Type','application/x-www-form-urlencoded'); | |
} | |
getProductsMagento(){ | |
this.appendHeaders(); | |
const options = new RequestOptions({headers: this.headers, method:'GET'}); | |
return this.http.get(this.URLProductos,options).map((res:Response) => res.json()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment