mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-12 08:31:05 +01:00
useMetadata docs updates
This commit is contained in:
parent
e4e2d13bd6
commit
98d91968a3
@ -3,6 +3,7 @@ import { useOcean } from '../../providers'
|
|||||||
import { feedback } from '../../utils'
|
import { feedback } from '../../utils'
|
||||||
import { DID, Logger, ServiceType } from '@oceanprotocol/lib'
|
import { DID, Logger, ServiceType } from '@oceanprotocol/lib'
|
||||||
import { checkAndBuyDT } from '../../utils/dtUtils'
|
import { checkAndBuyDT } from '../../utils/dtUtils'
|
||||||
|
|
||||||
interface UseConsume {
|
interface UseConsume {
|
||||||
consume: (
|
consume: (
|
||||||
did: DID | string,
|
did: DID | string,
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
Get metadata for a specific data asset.
|
Get metadata for a specific data asset.
|
||||||
|
|
||||||
`useMetadata` has 3 uses:
|
`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(did)` : it gets the DDO and then loads all the values (title, metadata etc)
|
||||||
- `useMetadata()` : loads nothing, useful for using functions like `getBestPrice` or `getBestPool` (maybe more in the future) with minimal calls
|
- `useMetadata(ddo)` : it uses the passed DDO and the loads all the values, in case you already got a list of DDOs, so you don't have to fetch the DDO once again
|
||||||
|
- `useMetadata()` : loads nothing, useful for using functions like `getPrice` or `getPool` with minimal calls
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -17,14 +18,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, bestPrice} = useMetadata(did)
|
const { title, metadata, price } = useMetadata(did)
|
||||||
|
|
||||||
const { main, additionalInformation } = metadata
|
const { main, additionalInformation } = metadata
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
<p>Price: {bestPrice}</p>
|
<p>Price: {price}</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user