我想在 ipfs 上发布文件,但它显示错误。
这是我的代码...
const ipfsClient = require('ipfs-http-client');
const ipfs = ipfsClient({host: 'ipfs.infura.io', port: 5001, protocol:
'https'});
function App() {
const [buffer, setBuffer] = useState();
const handleChange = (event) => {
event.preventDefault();
const file = event.target.files[0];
const reader = new window.FileReader();
reader.readAsArrayBuffer(file);
reader.onloadend = () =>{
setBuffer(reader.result);
}
}
const handleSubmit = async(event) => {
event.preventDefault();
console.log('submitting...')
await ipfs.add({buffer}, (error, result) => {
console.log('ipfs results');
if(error){
console.error(error);
return;
}
});
}
}
我在浏览器中收到此错误...
TypeError:ipfsClient 不是函数