Fetch
Fetch
import axios from "axios";export const fetchHnsDomainData = async (name: string) => { try { const domainDataResponse = await axios.get( `https://e.hnsfans.com/api/names/${name}` ); const domainHistoryResponse = await axios.get( `https://e.hnsfans.com/api/names/${name}/history` ); const fetchDomainData = await axios.get( `https://api.niami.io/domain/${name}` ); const fetchUnicodeData = await axios.get( `https://api.niami.io/domain/unicode/${name}` ); const fetchHsdData = await axios.get(`https://api.niami.io/hsd/${name}`); const fetchTxsData = await axios.get(`https://api.niami.io/txs/${name}`); const hnsDomainData = { ...domainDataResponse.data, history: domainHistoryResponse.data.result, domain: fetchDomainData.data, unicode: fetchUnicodeData.data, hsd: fetchHsdData.data, txs: fetchTxsData.data, }; return hnsDomainData; } catch (error) { throw new Error("Error fetching HNS domain data"); }};
key | value |
---|---|
fetchHnsDomainData | This function returns an object containing data related to an HNS domain. |
name | The HNS domain name to fetch data for. |
axios | A library used to make HTTP requests. |
domainDataResponse | The response from e.hnsfans.com API containing general domain data. |
domainHistoryResponse | The response from e.hnsfans.com API containing domain history data. |
fetchDomainData | The response from api.niami.io API containing domain data. |
fetchUnicodeData | The response from api.niami.io API containing unicode domain data. |
fetchHsdData | The response from api.niami.io API containing HSD data. |
fetchTxsData | The response from api.niami.io API containing transactions data. |
hnsDomainData | The combined object containing all fetched data. |
The fetchHnsDomainData
function is used to fetch data related to a Handshake domain name
. It takes a name parameter, which is the HNS domain name to fetch data for. The function uses the axios
library to make HTTP requests to various APIs and combines the fetched data into a single object, hnsDomainData
, which is returned by the function. If there is an error during the data fetching, the function will throw an error with the message "Error fetching HNS domain data".