Updating response for invalid address

This commit is contained in:
Jamie Hewitt 2022-08-24 17:05:52 +03:00
parent e776846c7a
commit d226949460
2 changed files with 2 additions and 3 deletions

View File

@ -9,7 +9,6 @@ export default async function getEnsAddress(
const ensName = request.query.name
const provider = await getProvider()
const address = await provider.resolveName(ensName)
if (!address) throw `No address found for ${ensName}`
response.setHeader('Cache-Control', 'max-age=0, s-maxage=86400')
response.status(200).send({ address })

View File

@ -3,7 +3,7 @@ import { getProvider } from './_utils'
export async function getEnsTextRecords(
ensName: string
): Promise<{ key: string; value: string }[]> {
): Promise<{ key: string; value: string }[] | null> {
const texts = [
'url',
'avatar',
@ -17,7 +17,7 @@ export async function getEnsTextRecords(
const records = []
const provider = await getProvider()
const resolver = await provider.getResolver(ensName)
if (!resolver) throw `No text records found for ${ensName}`
if (!resolver) return null
for (let index = 0; index < texts?.length; index++) {
const key = texts[index]