@@ -8,6 +8,7 @@ export class BaseQuery extends Pagination {
88
99 protected _client ! : AxiosInstance ;
1010 protected _urlPath ! : string ;
11+ protected _variants ! : string ;
1112
1213 /**
1314 * @method includeCount
@@ -16,7 +17,7 @@ export class BaseQuery extends Pagination {
1617 * @example
1718 * import contentstack from '@contentstack/delivery-sdk'
1819 *
19- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
20+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
2021 * const query = stack.contentType("contentTypeUid").entry().query();
2122 * const result = await query.includeCount().find()
2223 * // OR
@@ -37,7 +38,7 @@ export class BaseQuery extends Pagination {
3738 * @example
3839 * import contentstack from '@contentstack/delivery-sdk'
3940 *
40- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
41+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
4142 * const query = stack.contentType("contentTypeUid").entry().query();
4243 * const result = await query.orderByAscending("field_uid").find()
4344 * // OR
@@ -58,7 +59,7 @@ export class BaseQuery extends Pagination {
5859 * @example
5960 * import contentstack from '@contentstack/delivery-sdk'
6061 *
61- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
62+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
6263 * const query = stack.contentType("contentTypeUid").entry().query();
6364 * const result = await query.orderByDescending("field_uid").find()
6465 * // OR
@@ -79,7 +80,7 @@ export class BaseQuery extends Pagination {
7980 * @example
8081 * import contentstack from '@contentstack/delivery-sdk'
8182 *
82- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
83+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
8384 * const query = stack.contentType("contentTypeUid").entry().query();
8485 * const result = await query.limit("limit_value").find()
8586 * // OR
@@ -100,7 +101,7 @@ export class BaseQuery extends Pagination {
100101 * @example
101102 * import contentstack from '@contentstack/delivery-sdk'
102103 *
103- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
104+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
104105 * const query = stack.contentType("contentTypeUid").entry().query();
105106 * const result = await query.skip("skip_value").find()
106107 * // OR
@@ -123,7 +124,7 @@ export class BaseQuery extends Pagination {
123124 * @example
124125 * import contentstack from '@contentstack/delivery-sdk'
125126 *
126- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
127+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
127128 * const query = stack.contentType("contentTypeUid").entry().query();
128129 * const result = await query.param("key", "value").find()
129130 * // OR
@@ -144,7 +145,7 @@ export class BaseQuery extends Pagination {
144145 * @example
145146 * import contentstack from '@contentstack/delivery-sdk'
146147 *
147- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
148+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
148149 * const query = stack.contentType("contentTypeUid").entry().query();
149150 * const result = await query.addParams({"key": "value"}).find()
150151 * // OR
@@ -165,7 +166,7 @@ export class BaseQuery extends Pagination {
165166 * @example
166167 * import contentstack from '@contentstack/delivery-sdk'
167168 *
168- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
169+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
169170 * const query = stack.contentType("contentTypeUid").entry().query();
170171 * const result = await query.removeParam("query_param_key").find()
171172 * // OR
@@ -187,25 +188,37 @@ export class BaseQuery extends Pagination {
187188 * @example
188189 * import contentstack from '@contentstack/delivery-sdk'
189190 *
190- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
191+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
191192 * const result = await stack.asset().find();
192193 * @example
193194 * import contentstack from '@contentstack/delivery-sdk'
194195 *
195- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
196+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
196197 * const result = await stack.contentType("contentType1Uid").entry().query().find();
197198 * @example
198199 * import contentstack from '@contentstack/delivery-sdk'
199200 *
200- * const stack = contentstack.Stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
201+ * const stack = contentstack.stack ({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
201202 * const result = await stack.asset(asset_uid).fetch();
202203 */
203204
204205 async find < T > ( ) : Promise < FindResponse < T > > {
205206 let requestParams : { [ key : string ] : any } = this . _queryParams ;
206- if ( Object . keys ( this . _parameters ) ) requestParams = { ...this . _queryParams , query : { ...this . _parameters } } ;
207207
208- const response = await getData ( this . _client , this . _urlPath , requestParams ) ;
208+ if ( Object . keys ( this . _parameters ) . length > 0 ) {
209+ requestParams = { ...this . _queryParams , query : { ...this . _parameters } } ;
210+ }
211+
212+ const getRequestOptions : any = { params : requestParams } ;
213+
214+ if ( this . _variants ) {
215+ getRequestOptions . headers = {
216+ ...getRequestOptions . headers ,
217+ 'x-cs-variant-uid' : this . _variants
218+ } ;
219+ }
220+
221+ const response = await getData ( this . _client , this . _urlPath , getRequestOptions ) ;
209222
210223 return response as FindResponse < T > ;
211224 }
0 commit comments