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

avoid error if transactionHistoryRequest is not passed (especially while using js) #138

Closed
wants to merge 1 commit into from

Conversation

bhavya3024
Copy link

@bhavya3024 bhavya3024 commented May 10, 2024

While calling client.getTransactionHistory(transactionId), I was getting an error:

/home/bhavya/Documents/app-store-server-library-node/node_modules/@apple/app-store-server-library/dist/index.js:263
        if (transactionHistoryRequest.startDate) {
                                      ^

TypeError: Cannot read properties of undefined (reading 'startDate')
    at AppStoreServerAPIClient.getTransactionHistory (/home/bhavya/Documents/app-store-server-library-node/node_modules/@apple/app-store-server-library/dist/index.js:263:39)
    at /home/bhavya/Documents/app-store-server-library-node/test.js:16:45
    at Object.<anonymous> (/home/bhavya/Documents/app-store-server-library-node/test.js:18:3)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.10.0

I saw that I had to pass empty object client.getTransactionHistory(transactionId, null , {}) along with null value in previous argument, but I didn't have any parameters in my case, so I fixed it by checking the third argument if it does exist, and because I used javascript instead of typescript in my case, so typescript related error like the argument is required didn't came.

@federicobucchi @hkrdotptr @madrob @kolecke

@alexanderjordanbaker
Copy link
Collaborator

@bhavya3024 We feel that requiring the parameter and explicitly opting in to no parameters is a clearer style for users than allowing then to potentially omit the argument unintentionally

@bhavya3024
Copy link
Author

Ok,makes sense since sometimes we intentionally want user to filter out but the error should be friendly in nature, not like just cannot read properties of undefined or null, cant we add a check that that property should resemble a value ?

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

Successfully merging this pull request may close these issues.

None yet

2 participants