Что за? Кто подскажет?
Uncaught (in promise) TypeError: Cannot read property 'data' of undefined
Код:
function CustomJson() {
const [data, setData] = useState({obj: []});
useEffect(() => {
async function fetchData() {
const res = await axios(
'http://127.0.0.1:3001/ip/',
).then(res => {
console.log('axios error' + res);
// console.log(res.data);
});
setData(res.data);
}
fetchData().then(res => {
console.log('fetch error' + res);
});
}, [data]);
return (
<div>
{ data.obj }
</div>
);
}
Мне хотя-бы просто вывести что пришло.
Попробуй удалить data.lenght
Nurdan
Andrii
Ivan
Дмитрий
アレクサンダー・バキマトフ
Тимофей 🛴
Sergey
wolfe
Without Hands
Aleksandr
Мира
Андрей
shashkov0
Sm•ok
Китикет
Mihail