Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

browser-script-tag example don't work #1107

Closed
davidak opened this issue Nov 24, 2017 · 7 comments
Closed

browser-script-tag example don't work #1107

davidak opened this issue Nov 24, 2017 · 7 comments

Comments

@davidak
Copy link

davidak commented Nov 24, 2017

  • Version:
  • Platform: tested with Chromium 62 and Firefox 57
  • Subsystem:

Bug

Type: High

Severity:

Description:

files.cat don't give Text, only [object Object]

Steps to reproduce the error:

  1. open https://rawgit.com/ipfs/js-ipfs/master/examples/browser-script-tag/index.html
  2. copy and paste the example code into the JS console
  3. get:
index.min.js:82 Invalid asm.js: Type mismatch in assignment
index.min.js:247 Swarm listening on /dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star/ipfs/QmNgy2CDNRND5ALqEas8KfmAsPMeWPQnBi5W9UCV3GrCFj
index.html:10 Online status:  online

    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))
    })
undefined
VM56:7 successfully stored QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY
    node.files.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, data) {
      if (err) {
        return console.error('Error - ipfs files cat', err, res)
      }

      console.log(data.toString())
    })
  
undefined
VM58:6 [object Object]
@debrayc
Copy link

debrayc commented Nov 24, 2017

Ive actually been running through a bunch of the different js-ipfs examples and keep getting this same response... Currently following IPFS 101 which has some different code (at least in the 'cat' section) will let you know the results. Maybe try to change the 'cat' section with this code...

node.files.cat(fileMultihash, (err, data) => {
  if (err) { return cb(err) }

  console.log('\nFile content:')
  // print the file to the terminal and then exit the program
  process.stdout.write(data)
})

@daviddias
Copy link
Member

Hi there! The issue you are seeing is because the browser-script-tag example always uses the released version and we have one release in the works that has API changes #1095

Once the release is done you won't experience any more problems. If you want to try the example prepared for 0.26, you can check it out on the release tag https://github.com/ipfs/js-ipfs/releases/tag/v0.26.0

@ghost
Copy link

ghost commented Nov 27, 2017

Getting:
Uncaught TypeError: Cannot read property 'put' of undefined
Uncaught TypeError: Cannot read property 'get' of undefined

As Errors when I try to something with the code provided in the html.
Any suggestions ?

@daviddias
Copy link
Member

Hi @davidak @JohannesKnecht @debrayc , you can now try again the example. With js-ipfs 0.27.0 released, the examples on master are up to date. Let me know how it goes!

@ghost
Copy link

ghost commented Dec 11, 2017

@diasdavid Now another error is showing up:

Uncaught Error: Can't set property: 'links' is immutable
at module.exports.set links [as links] (index.min.js:1)
at Object.Buffer.serialize (index.min.js:1)
at cb (index.min.js:1)
at nextTask (index.min.js:1)
at exports.default (index.min.js:1)
at IPLDResolver._put (index.min.js:1)
at IPLDResolver.put (index.min.js:1)
at DAGNode.create (index.min.js:1)
at multihashing (index.min.js:1)
at Multihashing.Multihashing.digest (index.min.js:1)

@daviddias
Copy link
Member

There is a current known issue with the minified version, see more here: #1136

Meanwhile, use the non minified version to go over this issue -- https://github.com/ipfs/js-ipfs#use-in-the-browser

@ghost
Copy link

ghost commented Dec 11, 2017

Thank you ! It´s working

@daviddias daviddias added the status/ready Ready to be worked label Jan 25, 2018
@ghost ghost removed the status/ready Ready to be worked label Jan 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants