0

Im trying to get consentUrl but getting "Cannot read property 'authorizationUrl' of undefined".

Im using "xero-node": "^4.1.2"

const xero = new xero_node.XeroClient({
    clientId: "clientId",
    clientSecret: "clientSecret",
    redirectUris: ["redirectUrl"],
    scopes: "offline_access,openid".split(",")
});

then inside async function i'm calling this:

let consentUrl = await xero.buildConsentUrl();

and it gives error : Cannot read property 'authorizationUrl' of undefined.

Should I create url manually if this function is not supported. Need help thanks.

user606669
  • 1,674
  • 7
  • 27
  • 39

1 Answers1

0

try to execute await xero.buildClient();

before let consentUrl = await xero.buildConsentUrl();

  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – RyanNerd Feb 05 '20 at 06:47
  • 1
    The issue is that buildClient is an async method but since awaiting methods is not allowed in constructor, calling methods of client will result in calling them on not properly configured instance (buildClient method is not finished). So the only option is actually call this method right after initializing a new client. Original comment: https://github.com/XeroAPI/xero-node/issues/346#issuecomment-583330717 – Misha Masych Feb 07 '20 at 18:30