diff --git a/packages/fetch-api/public/index.tsx b/packages/fetch-api/public/index.tsx index 801df209..f8c7f270 100644 --- a/packages/fetch-api/public/index.tsx +++ b/packages/fetch-api/public/index.tsx @@ -138,6 +138,19 @@ const textTrending = async () => { console.error('textTrending', error) } } + +const extraQS = async () => { + try { + const gf = new GiphyFetch('sXpGFDGZs0Dv1mmNFvYaGUvYwKX0PWIh', { countryCode: 'us' }) + const result = await gf.trending({ + limit: 2, + type: 'text', + }) + console.log('extra qs', result) + } catch (error) { + console.error('extra qs', error) + } +} categories() search() searchChannel() @@ -154,4 +167,5 @@ text() textTrending() animate() searchVideos() +extraQS() relatedClips() diff --git a/packages/fetch-api/src/api.ts b/packages/fetch-api/src/api.ts index 6a2064e9..5f047b4c 100644 --- a/packages/fetch-api/src/api.ts +++ b/packages/fetch-api/src/api.ts @@ -21,21 +21,28 @@ const getType = (options?: TypeOption): MediaType => (options && options.type ? /** * @class GiphyFetch * @param {string} apiKey + * @param {object} qsParams */ export class GiphyFetch { - constructor(apiKey: string) { + constructor(apiKey: string, qsParams: Record = {}) { this.apiKey = apiKey + this.qsParams = qsParams } /** * @hidden */ private apiKey: string + + /** + * @hidden + */ + private qsParams: Record /** * @hidden */ private getQS = (options: any = {}) => { - return qs.stringify({ ...options, api_key: this.apiKey, pingback_id: getPingbackId() }) + return qs.stringify({ ...options, api_key: this.apiKey, pingback_id: getPingbackId(), ...this.qsParams }) } /**