Я пытаюсь получить JSON данные из корзины s3 с помощью React (в проекте Gatsby).
Это мой код.
import React from 'react';
function getJson() {
return fetch("http://secstat.info/testthechartdata.json")
.then((response) => response.json())
.then((responseJson) => {
return <div>{responseJson[0]}</div>;
})
.catch((error) => {
console.error(error);
});
};
export default getJson;
Это ошибка Я получаю.
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
Как мне это сделать? Вероятно, есть простой способ сделать это в Гэтсби, но я собирался использовать React.