fsyms is a required param
fetch запрос выдает ошибку
const API_URL_SEARCH = 'https://min-api.cryptocompare.com/data/pricemultifull'
const fetchData = () => {
fetch(API_URL_SEARCH, {
params: {
fsym: 'BTC',
tsym: 'USD',
}
})
.then(res => res.json())
.then(data => {
console.log(data);
return data;
})
.catch(error => {
console.error(error.message)
})
}
useEffect(() => {
fetchData();
}, [])
Ответы (1 шт):
Автор решения: iewher
→ Ссылка
Реализовал это таким способом:
const API_URL_SEARCH = 'https://min-api.cryptocompare.com/data/pricemultifull';
const fetchData = () => {
const params = new URLSearchParams();
params.append('fsyms', 'CAKE');
params.append('tsyms', 'USD');
return fetch(`${API_URL_SEARCH}?${params}`)
.then((res) => res.json())
.then((data) => {
return data;
})
.catch((error) => {
console.error(error.message);
});
};