Updted readme & error handling

This commit is contained in:
Jamie Hewitt 2022-08-18 17:23:04 +03:00
parent 9a36f47c9b
commit 926384840e
3 changed files with 30 additions and 3 deletions

View File

@ -64,3 +64,32 @@ Example response:
}
]
```
### Get ENS Profile
```
GET http://localhost:3000/api/profile?address=0x99840Df5Cb42faBE0Feb8811Aaa4BC99cA6C84e0
```
Example response:
```
{
"name": "jellymcjellyfish.eth",
"avatar": "https://metadata.ens.domains/mainnet/avatar/jellymcjellyfish.eth",
"links": [
{
"key": "url",
"value": "https://oceanprotocol.com"
},
{
"key": "com.github",
"value": "oceanprotocol"
},
{
"key": "com.twitter",
"value": "oceanprotocol"
}
]
}
```

View File

@ -7,10 +7,9 @@ export default async function getEnsAddress(
) {
try {
const ensName = request.query.name
console.log('ensName', ensName)
const ens = await getEns()
const address = await ens.name(ensName).getAddress()
console.log('address', address)
if (!address) throw `No address found for "${ensName}"`
response.setHeader('Cache-Control', 's-maxage=86400')
response.status(200).send(address)

View File

@ -63,7 +63,6 @@ export default async function EnsProfileApi(
try {
const accountId = String(request.query.address)
const profile = await getEnsProfile(accountId)
console.log('profile', profile)
response.setHeader('Cache-Control', 's-maxage=86400')
response.status(200).send(profile)