Closed r-token closed 3 years ago
Thank you for pointing this out, I think this might be an issue with the wording. window.hyperSDK
is the constructor for the SDK and not an instance of the SDK.
When you call await SDK(options)
you're creating an instance which you can then call Hyperdrive
and Hypercore
on.
Note the API example which has const sdk = await SDK()
here: https://github.com/datproject/sdk#apiexamples
A PR with better wording for that section would be appreicated.
Following the Building a bundle for Browsers section of the README, I wasn't able to get things to work until I changed:
const SDK = window.hyperSDK
toconst SDK = await window.hyperSDK()
within anasync
function.Using the original way, I was getting an error in the console saying
TypeError: this.Hypercore is not a function
Is this expected? If you'd like, I can submit a PR to update the README with an extra line of info showing that one may need to try it the
await
way.