From ad35c7fa721ffee924a254c54fa6d2fc1258911a Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Tue, 9 Feb 2021 23:57:16 -0500 Subject: [PATCH] Revert "Merge branch 'fix_null_bearer' into 'develop'" This reverts commit 22c3fa995d88b141249017c06dd76714123d2d7a, reversing changes made to 3931ba4f819302d0e215d41aa4b17dc2a5b182a7. --- app/javascript/gabsocial/api.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/javascript/gabsocial/api.js b/app/javascript/gabsocial/api.js index 19a80fa1..9d07fbaa 100644 --- a/app/javascript/gabsocial/api.js +++ b/app/javascript/gabsocial/api.js @@ -25,20 +25,16 @@ function setCSRFHeader() { ready(setCSRFHeader); -export default getState => { - const authToken = getState ? getState().getIn(['meta', 'access_token'], '') : null; +export default getState => axios.create({ + headers: Object.assign(csrfHeader, getState ? { + 'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`, + } : {}), - return axios.create({ - headers: Object.assign(csrfHeader, authToken ? { - 'Authorization': `Bearer ${authToken}}`, - } : {}), - - transformResponse: [function (data) { - try { - return JSON.parse(data); - } catch (Exception) { - return data; - } - }], - }); -}; + transformResponse: [function (data) { + try { + return JSON.parse(data); + } catch (Exception) { + return data; + } + }], +});