Open
Description
- I have clients with their SendPulse accounts
- I have firebase cloud functions as backend
Use case:
- Client A calls endpoint - everything is good
- Client B calls the same endpoint before that function is off - sendpulse uses Client A credentials.
I've tried everything:
- i import sendpulse inside function
- I create a new directory every time !!!
- I remove old directory every time
sendpulse.init receives correct API_USER_ID and API_SECRET every time but returns wrong data
exports.smsBalance = functions.https.onCall(async (data, context) => {
const { companyId } = data
const { API_USER_ID, API_SECRET } = await admin.database().ref('SendPulse/' + companyId)
.once('value')
.then(s => s.val())
const TOKEN_STORAGE = tempy.directory()
const sendpulse = require("sendpulse-api")
console.log(companyId, API_USER_ID, TOKEN_STORAGE)
return new Promise(resolve =>
sendpulse.init(API_USER_ID,API_SECRET,TOKEN_STORAGE, () =>
sendpulse.getBalance(
(data) => {
resolve(data.balance_currency)
},
'UAH'
)
)
)
})
.then(() => {
rimraf(TOKEN_STORAGE, () => console.log('cleaned up'))
})
I have no idea how to fix this. help appreciated.
Metadata
Metadata
Assignees
Labels
No labels