0
我在新的反应JS我只有25天的reactjs的经验,我想从嵌入式的URL获取数据,但我不明白如何使用它我使用的网址是(https://api.github.com/users/hadley/orgs)它是正确地获取数据,但我想从embed.ly中获取数据。这是我的页面反应名称是PostListItems.js 如何通过api嵌入reactjs中?
任何机构都可以帮助我提前感谢。
我在新的反应JS我只有25天的reactjs的经验,我想从嵌入式的URL获取数据,但我不明白如何使用它我使用的网址是(https://api.github.com/users/hadley/orgs)它是正确地获取数据,但我想从embed.ly中获取数据。这是我的页面反应名称是PostListItems.js 如何通过api嵌入reactjs中?
任何机构都可以帮助我提前感谢。
类型不是从Github的API返回的字段。
import React from 'react';
import { render } from 'react-dom';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
data: []
};
}
componentDidMount() {
fetch('https://api.github.com/users/hadley/orgs', {
method: 'GET',
})
.then((resp) => resp.json())
.then(data => {
this.setState({ data: data });
}).catch(error => {
console.log(error);
});
}
render() {
return <div>
{this.state.data.map((data, index) => {
return <div key={index}>{data.id}: {data.url}</div>
})}
</div>
}
}
render(<App />, document.getElementById('root'));
'type'并不显得API返回的关键。也许你应该在'.list-group-item'中使用'data.description'或'data.login'来代替'data.type'。 –
请勿发布您的代码的图片。发布您的代码。 – zero298