0

Here is a function that I have written to add a file on clicking a button, which calls the function 'onSubmit'

onSubmit = async (event) => {
 event.preventDefault()
 await ipfs.add(this.state.buffer, (err, ipfsHash1) => {
  console.log(err,ipfsHash1);
  this.setState({ ipfsHash:ipfsHash1[0].hash });
 });
}

Few weeks, I had run the same code and it had worked fine. I expected that the value of the hash will be stored in ipfsHash. But I get the error:

Unhandled Rejection (TypeError): Cannot read property '0' of undefined

What should I do? Please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.