Skip to content

Commit

Permalink
fix(passport): accessToken and customerId optinals (#2)
Browse files Browse the repository at this point in the history
* fix: accessToken and myId optinal at passport method

* Update src/methods/passport.js

Co-Authored-By: Leonardo Matos <leomp120894@gmail.com>
  • Loading branch information
talissonf and leomp12 committed Aug 20, 2019
1 parent f860764 commit bbbb77f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/methods/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const passport = ({
baseURL += storeId
}

let headers
if (customerId && accessToken) {
headers = {
'X-My-ID': customerId,
'X-Access-Token': accessToken
}
}

// returns axios request promise
return request({
data,
Expand All @@ -25,10 +33,7 @@ const passport = ({
baseURL,
method,
// setup authentication headers
headers: {
'X-My-ID': customerId,
'X-Access-Token': accessToken
}
headers
})
}

Expand All @@ -42,8 +47,8 @@ const passport = ({
*
* @param {object} cfg - Request config options
* @param {string} cfg.url - API endpoint to request or absolute URI
* @param {string} cfg.customerId - My ID for authenticated request
* @param {string} cfg.accessToken - Access token for authenticated request
* @param {string} [cfg.customerId] - My ID for authenticated request
* @param {string} [cfg.accessToken] - Access token for authenticated request
* @param {string} [cfg.method='get'] - Request method (HTTP verb)
* @param {object} [cfg.data] - Request body object
* @param {number} [cfg.storeId=_config.get('store_id')] - E-Com Plus Store ID number
Expand Down

0 comments on commit bbbb77f

Please sign in to comment.