$("#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)
readervariable gets created. Error is saying that value is null. – Shawn Tabrizi Dec 31 '18 at 15:28saveOnIpfs? Please write full code here. – Monarth Sarvaiya Jan 01 '19 at 05:16