我正在尝试在我的反应组件中显示json响应
class JsonComponents extends React.Component {
constructor() {
super();
this.state = {
components: []
};
}
_fetchComponents() {
jQuery.ajax ({
method: 'GET',
url: 'https://api.github.com/users/mralexgray/repos',
success: (components) => {
this.setState({components})
console.log("Logging something ", this.state.components);
}
});
}
componentWillMount() {
this._fetchComponents();
}
render() {
// HOw to parse JSON and render it in a table in JSX?
return <div><pre>{JSON.stringify(this.state.components, null, 2) }</pre></div>;
}
}
ReactDOM.render(<JsonComponents />,
document.getElementById('container'));
请问我解析返回的json并仅从响应中呈现一个键吗?