Lesson 10: TypeError: Cannot read properties of undefined (reading 'toString') #6615
Unanswered
YashGolani
asked this question in
Q&A
Replies: 1 comment
-
Hi @YashGolani This is some common error if you are using java script instead of type script. Entrance fee is const entranceFeeFromCall = parseFloat(ethers.utils.formatEther((getEntranceFee() as BigNumber) || 0)) // considers case when getEntranceFee is not returning value for some reason
// or
const entranceFeeFromCall = ((await getEntranceFee()) as BigNumber).toString() The point is that if your getEntranceFee is not returning value it will throw "Cannot read properties of undefined..." to handle this you need either use or statement as I shown above -> (if getEntrance returns value get this value and if not get 0 instead) or you just make sure somehow that this value will be always delivered. In my opinion you should always consider all possible options and typescript helps with that a lot. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
LotteryEntranceFee.js
02-update-frontend.js
Beta Was this translation helpful? Give feedback.
All reactions