Read from Decentralized Web Nodes
Before reading from your Decentralized Web Node (DWN), be sure to check out our Quickstart guide to ensure you’ve properly imported the Web5 SDK. Additionally, make sure you’ve set up a DID before attempting to read from a DWN.
Read from a DWN
The following snippet allows you to read from your Web5
instance’s DWN:
// Create the record
const myRecord = await web5.dwn.records.create(myDid.id, {
author: myDid.id,
data: "Hello Web5",
message: {
dataFormat: 'text/plain',
},
});
// Read the record
const readResult = await myRecord.record.data.text();