-
Notifications
You must be signed in to change notification settings - Fork 44
Ipfs.node.dag.get fails in Chapter 2 of the tutorial #140
Comments
Even after i included the script above, i get the error that 'CID is not defined'. I also tried with the scrips the cids package included, but i get a 404 error. |
Turns out the CID package is not necessary. It is possible to create a new CID using IPFS with |
I confirm the finding of @santiag0m and of @matheusmartins56: the REPL command I traced the error in the different packages of This statement is
Googling around, I found this old "inactive" doc of I found the current docs here and the code of the tutorial doesn't seem to match this doc. I might be mistaking but my guess is that there has been a breaking change in one of the npm packages between the moment the tutorial was made and today.I'll try and set it straight, but with no guarantees, I'm really a beginner. :) |
I think I'm getting closer to the bug.
The function The previous call was to Calling on @aphelionz for confirmation? |
It's confirmed: the problem lies in the REPL instruction given in the tutorial, the module Try 1. I tried to use the counterpart of
the error was no more triggered. But the result is empty: kvutien@VTKT5 orbitdb-ch1 % node --experimental-repl-await
...
> cid
'zdpuAnDVaC6371n8ik8SQCAb43ebYkLm1XXhgwqXikhnUHSQB'
> content = await NPP.pieces.get(cid)
[] Try 2. I made a JavaScript program to use /*
* Main JavaScript program to check the cid returned by ipfs.add
*/
const Ipfs = require ('ipfs-core');
async function create() {
console.log(' --> calling create IPFS node;')
// create an IPFS node
const node = await Ipfs.create({
preload: {enabled: false},
repo: './ipfs',
config: {
Bootstrap: [],
Addresses: {Swarm: []}
}
})
const cid = await node.dag.put({name: 'test'});
console.log(' ---> cid.multihash =', cid.multihash)
}
create(); The ouput is
|
To run on the browser, you need to modify the code as follows: |
thanks it works remplacing |
Cool
I'll try. Thanks.
--
Vu Tien Khang
… Le 1 déc. 2021 à 07:15, lilian131 ***@***.***> a écrit :
@kvutien <https://github.com/kvutien>
To run on the browser, you need to modify the code as follows: const content = await NPP.node.dag.get(new NPP.Ipfs.CID(cid))
thanks it works remplacing NPP.node.dag.get(Ipfs.asCID(cid)) by NPP.node.dag.get(new NPP.Ipfs.CID(cid))
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#140 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AHY2OURHYIWJ4C22PS5DDV3UOW4RZANCNFSM46TIJWMA>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I believe this was updated in the latest PR, so closing |
I was following the tutorial but got stuck for a while in Chapter 2 with the following error:
After searching similar issues in IPFS, I found this one: ipfs/js-ipfs#3689 . Turns out that IPFS now expects a
CID
object when handling content.I was able to fix it by adding a CID constructor in the
NewPiecePlease
class.To do this I had to install the cids npm package. For it to work in the browser I added the following script tag (for version 1.1.4 as newer versions are not available):
The text was updated successfully, but these errors were encountered: