2
  $("#image").change(function(event) {
    const file = event.target.files[0]
    reader = new window.FileReader()
    reader.readAsArrayBuffer(file)
  });

function saveOnIpfs(reader) {
    return new Promise(function(resolve, reject) {
      const buffer = Buffer.from(reader.result);
      ipfs.add(buffer)
      .then((response) => {
        console.log(response)
        resolve(response[0].hash);
      }).catch((err) => {
        console.error(err)
        reject(err);
      })
    })
  }

this is the error i get in the console

index.js:107 Uncaught (in promise) TypeError: Cannot read property 'result' of undefined
    at index.js:107
    at new Promise (<anonymous>)
    at new t (_export.js:36)
    at HTMLFormElement.<anonymous> (index.js:106)
    at HTMLFormElement.dispatch (jquery.min.js:3)
    at HTMLFormElement.q.handle (jquery.min.js:3)
  • Looks like you will need to share how the reader variable gets created. Error is saying that value is null. – Shawn Tabrizi Dec 31 '18 at 15:28
  • ok i send you code – Josue Guessennd Dec 31 '18 at 15:53
  • $("#image").change(function(event) { const file = event.target.files[0] reader = new window.FileReader() reader.readAsArrayBuffer(file) }); – Josue Guessennd Dec 31 '18 at 15:55
  • from where you are calling the function saveOnIpfs ? Please write full code here. – Monarth Sarvaiya Jan 1 at 5:16

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.