Everything I want to do is take a ipfs hash and output the corresponding element.
I forked https://github.com/ipfs/js-ipfs/tree/master/examples/browser-script-tag
however when trying to use the API nothing works (replace code with script and it says undefined ??)
could you please provide a single working (static) example ?
It would be great to get started with ipfs
hi
maybe that can help you : https://ipfs.io/ipfs/QmdPtC3T7Kcu9iJg6hYzLBWR5XCDcYMY7HV685E3kH3EcS/2015/09/15/hosting-a-website-on-ipfs/
The problem isn´t hosting the site on ipfs, I´m not able to connect to IPFS using Javascript (on a static website)
test that in your website : https://gist.github.com/josselinchevalay/88ab454475127ff27004e2e3220ebcea
Was able to run that, however when trying to get or put a object from/ to ipfs it failed.
Would be awesome if you could share any demo that executes the ipfs get file command successfully.
I would like to execute that successfully:
node.files.add(new node.types.Buffer('Hello world!'), (err, filesAdded) => {
if (err) {
return console.error('Error - ipfs files add', err, res)
}
filesAdded.forEach((file) => console.log('successfully stored', file.hash))
})
+
node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, data) {
if (err) {
return console.error('Error - ipfs files cat', err, res)
}
console.log(data.toString())
})
try that :
ipfs.files.cat(ipfsPath, function (err, file) {
if (err) {
throw err
}
console.log(file.toString(‘utf8’))
})
do you have proxy ?
const node = new Ipfs({ repo: 'ipfs-' + Math.random() })
node.once('ready', () => {
console.log('Online status: ', node.isOnline() ? 'online' : 'offline')
})
node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, file) {
if (err) {
throw err
}
console.log(file.toString('utf8'))
})
Returns:
“Uncaught TypeError: Cannot read property ‘get’ of undefined”
I don´t have a proxy
beware you need include node.files on node.ready event : you need IPFS node is ready to request on it
Thank you so much <3