Under Home - Documentation there is a neat little example given.
// write new data to the network
app.immutableData.create().then((writer)=> {
return writer.write("some string\n")
.then(() => writer.write("second string"))
.then(() => writer.close())
.then((address) => app.immutableData.fetch(address)
.then((reader) => reader.read()
.then( (payload) => {
should(payload).equals("some string\nsecond string");
})
))
})
Sadly there is an issue with it. I am using version 0.5.3
of the API and I am getting this error…
TypeError: Cannot read property ‘ref’ of undefined
It looks to me that Home - Documentation needs a cipherOpt to function. What is confusing is the documentation says that it takes two parameters, close(cipherOpt: any, the: CipherOpt)
. When looking at the code it only takes one parameter…
/**
* Close and write the immutable Data to the network.
*
* @param {CipherOpt} the Cipher Opt to encrypt data with
* @returns {Promise<String>} the address to the data once written to the network
*/
I am assuming this is because the documentation is out of sync with the code. Or maybe I am being incredibly silly, it has happened once or twice before. Could anyone give a suggestion on how this example would be updated? I have tried changing the line to include a newPlainText()
inside the close() call but to no avail.