Skip to content

Commit cb18ed4

Browse files
authored
fix: expose token on client (#207)
1 parent 3bd277d commit cb18ed4

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.4.2 / 2021/08/25
2+
===================
3+
- Fix: Exposing token on ApifyClient instance
4+
15
1.4.1 / 2021/08/24
26
===================
37
- Changed passing token using request HTTP header instead of the request parameter for every API calls

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apify-client",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Apify API client for JavaScript",
55
"main": "src/index.js",
66
"keywords": [

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ApifyClient {
6262

6363
const tempBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, baseUrl.length - 1) : baseUrl;
6464
this.baseUrl = `${tempBaseUrl}/v2`;
65+
this.token = token;
6566
this.stats = new Statistics();
6667
this.logger = logger.child({ prefix: 'ApifyClient' });
6768
this.httpClient = new HttpClient({
@@ -71,7 +72,7 @@ class ApifyClient {
7172
requestInterceptors,
7273
timeoutSecs,
7374
logger: this.logger,
74-
token,
75+
token: this.token,
7576
});
7677
}
7778

test/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ describe('ApifyClient', () => {
1212
client = new ApifyClient({ baseUrl: `${exampleUrl}/` });
1313
expect(client.baseUrl).toBe(`${exampleUrl}/v2`);
1414
});
15+
test('token correctly set', () => {
16+
const token = 'myToken';
17+
const client = new ApifyClient({ token });
18+
expect(client.token).toBe(token);
19+
});
1520
});

0 commit comments

Comments
 (0)