11import { Query } from "./query" ;
2- import { AxiosInstance } from "@contentstack/core" ;
2+ import { AxiosInstance , getData } from "@contentstack/core" ;
3+ import { FindResponse } from "./types" ;
34
45export class TaxonomyQuery extends Query {
5- constructor ( client : AxiosInstance ) {
6- super ( client , { } , { } ) ; // will need make changes to Query class so that CT uid is not mandatory
7- this . _client = client ;
8- this . _urlPath = `/taxonomies/entries` ;
9- }
10- } ;
6+ constructor ( client : AxiosInstance ) {
7+ super ( client , { } , { } ) ; // will need make changes to Query class so that CT uid is not mandatory
8+ this . _client = client ;
9+ this . _urlPath = `/taxonomies/entries` ;
10+ }
11+ /**
12+ * @method find
13+ * @memberof TaxonomyQuery
14+ * @description Fetches all taxonomies of the stack using /taxonomy-manager endpoint
15+ * @returns {Promise<FindResponse<T>> }
16+ * @example
17+ * import contentstack from '@contentstack/delivery-sdk'
18+ *
19+ * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
20+ * const taxonomyQuery = stack.taxonomy();
21+ * const result = await taxonomyQuery.find();
22+ */
23+ override async find < T > ( ) : Promise < FindResponse < T > > {
24+ this . _urlPath = "/taxonomy-manager" ; // TODO: change to /taxonomies
25+ const response = await getData ( this . _client , this . _urlPath , {
26+ params : this . _queryParams ,
27+ } ) ;
28+
29+ return response as FindResponse < T > ;
30+ }
31+ }
0 commit comments