I have spent hours over the last few days trying to figure out how to do a callback to get data out of a function I am importing from a node module and use it with context.res in an azure function.
I don't understand callbacks well enough to get my head around this, or I am completely off base.
module.exports = function (context, req) {
var QuickBooks = require('node-quickbooks')
var qboAuth = require('./config')
var consumerKey = qboAuth.consumerKey
var consumerSecret = qboAuth.consumerSecret
var oauthToken = qboAuth.token
var oauthTokenSecret = qboAuth.tokenSecret
var realmId = qboAuth.realmId
var qbo = new QuickBooks(consumerKey,
consumerSecret,
oauthToken,
oauthTokenSecret,
realmId,
false, // use the sandbox?
true); // enable debugging?
qbo.getAccount(req.query.id, function(err, account) {
context.log(account)
} );
context.res = {
body: account
}
context.done()
}
So the context.log(account) in the qbo.getAccount() function outputs fine, however through which ever means I use I cannot get this to output to context.res = {}.
I think this is complicated by running in the Azure Function sandbox, but I am not sure.
Is someone able to point me in the right direction?
Thanks,
Dion
via Dion Goile
No comments:
Post a Comment