Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'NA' of undefined #6

Open
ekkis opened this issue May 1, 2022 · 7 comments
Open

TypeError: Cannot read property 'NA' of undefined #6

ekkis opened this issue May 1, 2022 · 7 comments

Comments

@ekkis
Copy link
Collaborator

ekkis commented May 1, 2022

followed the simple instructions in the README. I have a file with the sample code and when I run it I get the following:

$ node acogd.js 

/Users/ekkis/dev/node_modules/agcod/index.js:80
const endpoint = this.config.endpoint[region]
^

TypeError: Cannot read property 'NA' of undefined
at module.exports._getSignedRequest (/Users/ekkis/dev/node_modules/agcod/index.js:80:42)
at module.exports.createGiftCard (/Users/ekkis/dev/node_modules/agcod/index.js:15:32)
at Object. (/Users/ekkis/dev/acogd.js:4:8)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47

what am I missing?

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

I've had a gander at the code. I can see that the missing information is in the config/default.json in the package but I don't see that the code loads that anywhere

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

changing the constructor to something like this makes it work:

module.exports = class {
  constructor(cfg = {}) {
    this.config = Object.assign(require('./config/default.json'), cfg);
  }

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

also missing from the documentation is the fact that the client initialisation needs to be given credentials. something like this:

const client = new Client(require('./config/sandbox.json'))

with a little modification to the code it could be called without a parameter. my recommendation would be that for niladic calls the code look in ./acogd for the files and that it use the NODE_ENV environment variable to look for the name of the file, defaulting to development if not set

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

if the above is acceptable I'm happy to submit a PR

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

as a nice enhancement, I would make the call to createGiftCard accept a country code instead of a region. this would allow developers to create a list of the supported countries, so they can present them to the user since users don't know and don't care about regions, then that can be fed to the call. again, if these enhancements are welcome, I'm happy to submit a PR. please advise

@ekkis
Copy link
Collaborator Author

ekkis commented May 1, 2022

also, I don't know if it's possible to create a USD card for Japan. probably not. in that case we should codify the currencies for the countries involved so the createGiftCard doesn't have to be supplied it

@ekkis
Copy link
Collaborator Author

ekkis commented May 2, 2022

see 'Sundry fixes' PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant