-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.key.read is not a function error when using random-access-memory with hello world example #160
Comments
Also seeing this with const hypercore = require('hypercore')
const randomAccessIDB = require('random-access-idb')
const storage = (typeof window === 'undefined') ? './feed' : randomAccessIDB
const feed = hypercore(storage, {valueEncoding: 'utf-8'})
feed.append('hello')
feed.append('world', (error) => {
if (error) throw error
feed.get(0, console.log)
feed.get(1, console.log)
}) |
You have to instantiate the instance returned. |
Ah, thanks, @mafintosh – RTFM apparently doesn’t work if you can’t copy what you see properly 🤦 (I’m making progress with the IDB version. I’ll post the fixed code for that once I have it running too in case anyone else stumbles onto this and then I’ll close the issue.) |
I updated the const hypercore = require('hypercore')
const randomAccessIDB = require('random-access-idb')
const storage = (typeof window === 'undefined') ? './feed' : function () { return randomAccessIDB('hypercore-spike')('feed') }
const feed = hypercore(storage, {
valueEncoding: 'utf-8',
overwrite: true
})
feed.append('hello', function (error) {
if (error) throw error
feed.append('world', function (error) {
if (error) throw error
feed.get(0, console.log) // <-- Error: No node found
feed.get(1, console.log)
})
}) |
const browserStorage = randomAccessIDB('cool-stuff')
const feed = hypercore(filename => browserStorage(filename)) |
@mafintosh Ah, gotcha, I was thinking about it all wrong. Thank you :) |
To reproduce
The error
Environment
package.json dependencies:
The text was updated successfully, but these errors were encountered: