Skip to content

Commit

Permalink
Fix axios issue
Browse files Browse the repository at this point in the history
  • Loading branch information
itsokto committed Jan 25, 2022
1 parent 8c6e341 commit 23d5df9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion duck-node/package.json
@@ -1,6 +1,6 @@
{
"name": "duck-node",
"version": "1.2.5",
"version": "1.2.6",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions duck-node/src/constants.ts
@@ -1,5 +1,5 @@
const baseURL = 'https://duckduckgo.com/';
const imagesURL = 'i.js/';
const baseURL = 'https://duckduckgo.com';
const imagesURL = '/i.js';
const vqdRegex = new RegExp("vqd='?(?<vqd>[\\w\\-]+)'?");

export default { baseURL, imagesURL, vqdRegex };
4 changes: 2 additions & 2 deletions duck-node/src/duck.api.ts
Expand Up @@ -35,7 +35,7 @@ export class DuckApi {
}

async getToken(query: string): Promise<string> {
const response = await this._client.get<string>('', { params: { q: query } });
const response = await this._client.get<string>('/', { params: { q: query } });

const math = constants.vqdRegex.exec(response.data);
if (math?.groups) {
Expand All @@ -47,7 +47,7 @@ export class DuckApi {

async getImages(query: string, strict: DuckStrict = DuckStrict.Off): Promise<AxiosResponse<DuckResponse<DuckImage>>> {
const vqd = await this.getToken(query);
return this._client.get<DuckResponse<DuckImage>>('i.js', {
return this._client.get<DuckResponse<DuckImage>>(constants.imagesURL, {
params: { q: query, p: strict, vqd, o: 'json', f: ',,,', l: 'us-en' },
});
}
Expand Down

0 comments on commit 23d5df9

Please sign in to comment.