0
I’m creating a service
in angular
who consumes a package to consult a api
, but I always get the same mistake;
Can’t resolve all Parameters for Apiservice: (?).
the Code:
import { Injectable, Inject } from '@angular/core';
import { WooCommerceAPI } from 'woocommerce-api';
@Injectable()
export class ApiService {
woocommerce: any;
constructor(@Inject(WooCommerceAPI) woocommerce: WooCommerceAPI) {
this.woocommerce = woocommerce({
url: 'http://wc-project.dev/',
consumerKey: 'ck_123',
consumerSecret: 'cs_123',
wpAPI: true,
version: 'wc/v2'
});
}
getProducts(): any {
return this.woocommerce.get('products');
}
}
I’ve tried using with OnInit
but I get the bug
this.Woocommerce is Undefined
as the function ngOnInit
is started even before the declaration of attributes until I understand this error.
But how can I use the api package in my service
?