0

I im new in react js i have only 25 days of experience of reactjs and i am trying to fetch the data from url of embedly but i can not understand how to use it i am using the url which is ( https://api.github.com/users/hadley/orgs ) it is fetch the data correctly but i want to fetch the data from the embed.ly this is my page in react name is PostListItems.js enter image description here

can any body help me thanks in advance.

2
  • type does not appear to be a key returned by the API. Maybe you should use data.description or data.login instead of data.type in your .list-group-item. Commented Oct 9, 2017 at 16:39
  • Do not post pictures of your code. Post your code. Commented Oct 9, 2017 at 17:16

1 Answer 1

1

Type isn't a field that is returned from Github's 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'));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.