ens-proxy/pages/api/address.ts

21 lines
567 B
TypeScript
Raw Normal View History

2022-08-18 15:51:38 +02:00
import { NextApiRequest, NextApiResponse } from 'next'
import { getEns } from './_utils'
export default async function getEnsAddress(
request: NextApiRequest,
response: NextApiResponse
) {
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)
response.setHeader('Cache-Control', 's-maxage=86400')
response.status(200).send(address)
} catch (error) {
response.status(500).send(`${error}`)
}
}