Skip to content

Commit

Permalink
feat: always send _user_key as GET parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Idered committed Nov 20, 2017
1 parent d808523 commit 2098477
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions packages/lib-js-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ function SyncanoClient (instanceName = required('instanceName'), options = {}) {
}

client.url = function (endpoint, data) {
let url = `${this.baseUrl}${endpoint}/?`

if (data) {
return `${this.baseUrl}${endpoint}/?${querystring.stringify(data)}`
url += `${querystring.stringify(data)}&`
}

if (client.token) {
url += `_user_key=${client.token}`
}

return `${this.baseUrl}${endpoint}/`
return url
}

client.logout = function () {
Expand Down Expand Up @@ -171,20 +177,11 @@ function SyncanoClient (instanceName = required('instanceName'), options = {}) {

const transformRequest = [
function (data) {
const token = client.token ? {_user_key: client.token} : {} // eslint-disable-line camelcase

if (data instanceof window.FormData) {
if (client.token) {
data.append('_user_key', client.token)
}

return data
}

return JSON.stringify({
...data,
...token
})
return JSON.stringify(data)
}
]

Expand Down

0 comments on commit 2098477

Please sign in to comment.