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");  }};
keyvalue
fetchHnsDomainDataThis function returns an object containing data related to an HNS domain.
nameThe HNS domain name to fetch data for.
axiosA library used to make HTTP requests.
domainDataResponseThe response from e.hnsfans.com API containing general domain data.
domainHistoryResponseThe response from e.hnsfans.com API containing domain history data.
fetchDomainDataThe response from api.niami.io API containing domain data.
fetchUnicodeDataThe response from api.niami.io API containing unicode domain data.
fetchHsdDataThe response from api.niami.io API containing HSD data.
fetchTxsDataThe response from api.niami.io API containing transactions data.
hnsDomainDataThe 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".