diff --git a/src/onDeleteAccount.js b/src/onDeleteAccount.js index aba5bbc230372435293e28af0b297e9895e4f34c..015bb91d1a9570d4f6e11bd893ffd823c30d2439 100644 --- a/src/onDeleteAccount.js +++ b/src/onDeleteAccount.js @@ -55,10 +55,10 @@ async function fetchNewAccessToken(accountSecret) { // split the result into an array of strings containing a single json object // then check if the resulting json has an access_token field // return it if it does or return undefined - return result.match(/.+/g).map(s => { - result = JSON.parse(s) - if (result.access_token) { - return result.access_token + return result.match(/.+/g).map(jsonString => { + const jsonObject = JSON.parse(jsonString) + if (jsonObject.access_token) { + return jsonObject.access_token } }) })