Hello I am using React and typescript with coinAPI. I have a question how can I get type of data. Because now I use type unknown and I can not use the data inside my project. What to do?
const SearchForm: React.FC<funcProps> = (props) => {
const [assetName, setAssetName] = useState<string>("");
const onChangeInputHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
setAssetName(e.target.value);
};
const onSearchSubmitHandler = async () => {
const getData = async () => {
const response = await fetch(
`https://rest.coinapi.io/v1/assets/${assetName}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
"X-CoinAPI-Key": "key",
},
}
);
const data = await response.json();
console.log(data);
props.setAsset(data);
};
getData();
};