Skip to content

Commit 94b074f

Browse files
authored
Merge pull request #1 from preprio/compatibility-fix
Fix: syntax compatibility on 23, Feb 2021
2 parents 8a05cc6 + 117cb6e commit 94b074f

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
tabWidth: 2,
4+
printWidth: 80,
5+
vueIndentScriptAndStyle: false,
6+
quoteProps: 'consistent',
7+
semi: false,
8+
singleQuote: true,
9+
trailingComma: 'all',
10+
}

lib/index.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ class PreprClient {
1414
this._token = token
1515
this._baseUrl = baseUrl
1616
this._timeout = timeout
17+
this._abTestingValue = null
18+
this._hasAbTesting = false
1719

1820
userId && this._hashUserId(userId)
1921
}
2022

21-
_abTestingValue = null
22-
_hasAbTesting = false
23-
2423
_hashUserId(userId) {
2524
const hashValue = murmurhash.v3(userId, 1)
2625
const ratio = hashValue / Math.pow(2, 32)
@@ -96,20 +95,25 @@ class PreprClient {
9695

9796
const requestString = `${this._baseUrl}${this._path}?${hasQueryString}`
9897

99-
const abTestingHeaders = this._hasAbTesting && {
100-
'Prepr-ABTesting': this._userId,
98+
const headers = {
99+
Authorization: `Bearer ${this._token}`,
100+
}
101+
102+
Object.assign(headers, options.headers)
103+
104+
if (this._hasAbTesting) {
105+
Object.assign(headers, {
106+
'Prepr-ABTesting': this._userId,
107+
})
101108
}
102109

103110
const requestOptions = {
104-
...options,
105111
signal: controller.signal,
106-
headers: {
107-
...options.headers,
108-
...abTestingHeaders,
109-
Authorization: `Bearer ${this._token}`,
110-
},
112+
headers,
111113
}
112114

115+
Object.assign(requestOptions, options)
116+
113117
try {
114118
const response = await fetch(requestString, requestOptions)
115119

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@preprio/nodejs-sdk",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Prepr Node.js SDK",
55
"main": "lib/index.js",
66
"directories": {

0 commit comments

Comments
 (0)