From 926384840ec9d71399fbbeacbcdc038d8480f0d8 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 18 Aug 2022 17:23:04 +0300 Subject: [PATCH] Updted readme & error handling --- README.md | 29 +++++++++++++++++++++++++++++ pages/api/address.ts | 3 +-- pages/api/profile.ts | 1 - 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d484b98..eff270c 100644 --- a/README.md +++ b/README.md @@ -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" + } + ] +} +``` diff --git a/pages/api/address.ts b/pages/api/address.ts index da77270..46af009 100644 --- a/pages/api/address.ts +++ b/pages/api/address.ts @@ -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) diff --git a/pages/api/profile.ts b/pages/api/profile.ts index e7cf1e1..ca0c181 100644 --- a/pages/api/profile.ts +++ b/pages/api/profile.ts @@ -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)