1
      .addMedicalReport(
        patientBio.id,
        patientBio.name,
        patientBio.birthDate,
        patientBio.phoneNumber,
        patientBio._address,
        patientBio.MedReportId,
        parseInt(patientMedicalData.weight),
        parseInt(patientMedicalData.height),
        patientMedicalData.bloodGroup,
        patientMedicalData.diseaseName,
        patientMedicalData.diseaseDescription,
        patientMedicalData.diseaseStartedOn
      ).send({ from: account })
      .once('receipt', (receipt) => {
        console.log('saved')
        // updateList(patientDataContract)
      }) 

solidity

function addMedicalReport(
    string memory patientId,
    string memory patientName, 
    string memory birthDate, 
    string memory phoneNumber, 
    string memory _address,
    string memory medReportId,
    uint weight,
    uint height,
    string memory bloodGroup,
    string memory diseaseName,
    string memory diseaseDescription,
    string memory diseaseStartedOn
    ) public {
      countSenders++;
    }

Error:

*react-dom.development.js:4091 Uncaught TypeError: Cannot read property 'length' of undefined
    at toUtf8Bytes (utf8.ts:210)
    at StringCoder.encode (string.ts:15)
    at array.ts:62
    at Array.forEach (<anonymous>)
    at pack (array.ts:54)
    at TupleCoder.encode (tuple.ts:23)
    at AbiCoder.encode (abi-coder.ts:106)
    at ABICoder.webpackHotUpdate../node_modules/web3-eth-abi/lib/index.js.ABICoder.encodeParameters (index.js:121)
    at index.js:439
    at Array.map (<anonymous>)
    at Object._encodeMethodABI (index.js:438)
    at Object._processExecuteArguments (index.js:701)
    at Object._executeMethod (index.js:720)
    at addUpdatePatientMedicalData (App.js:100)*
1
  • Hello. We need more of your javascript code. As it is clearly sayed in the error, something is indefined. – Florian Castelain May 6 at 6:28
1

The error was because of a typo mistake. I was passing an undefined argument which caused this error. Its not an error because of no. of arguments.

Not the answer you're looking for? Browse other questions tagged or ask your own question.