I have this service and I need to return the products to components I don't use here the HttpClient or Observable as I don't need them
export class StoreDataProvider {
private _wooData: any;
constructor() {
this._wooData = Woo({
url: 'http://example.com/',
consumerKey: 'key here',
consumerSecret: 'key here',
wpAPI: true,
version: 'wc/v3'
});
}
getAllProducts() {
return this._wooData.get('products', (err, data, res) => {
return res
});
}
}
The code above returns the headers, not the products but if I console the products inside the service itself instead of return I get the products! the code be will like this:
export class StoreDataProvider {
private _wooData: any;
constructor() {
this._wooData = Woo({
url: 'http://example.com/',
consumerKey: 'key here',
consumerSecret: 'key here',
wpAPI: true,
version: 'wc/v3'
});
}
getAllProducts() {
this._wooData.get('products', (err, data, res) => {
console.log(res);
});
}
}
The code in the component is just console.log( this._wooService.getAllProducts() )
if I console log at the service
So what am I missing here?