mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
metadata readme
This commit is contained in:
parent
f9b1e7a530
commit
a488ae51ca
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
Get metadata for a specific data asset.
|
Get metadata for a specific data asset.
|
||||||
|
|
||||||
|
`useMetadata` has 3 uses:
|
||||||
|
- `useMetadata(did)` : it gets the ddo and then loads all the values (title, metadata etc)
|
||||||
|
- `useMetadata(ddo)` : it uses the passed ddo and the loads all the values, in case you already got a list of ddo, so you don't have to fetch the ddo once again
|
||||||
|
- `useMetadata()` : loads nothing, useful for using functions like `getBestPrice` or `getBestPool` (maybe more in the future) with minimal calls
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
@ -12,14 +17,14 @@ const did = 'did:op:0x000000000'
|
|||||||
|
|
||||||
export default function MyComponent() {
|
export default function MyComponent() {
|
||||||
// Get metadata for this asset
|
// Get metadata for this asset
|
||||||
const { ddo, title, metadata } = useMetadata(did)
|
const { ddo, title, metadata, bestPrice} = useMetadata(did)
|
||||||
|
|
||||||
const { main, additionalInformation } = metadata
|
const { main, additionalInformation } = metadata
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
<p>Price: {main.price}</p>
|
<p>Price: {bestPrice}</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user