Shahid Hussain
Shahid Hussain

Reputation: 157

How to use embedly in reactjs through api?

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.

Upvotes: 0

Views: 689

Answers (1)

Win
Win

Reputation: 5584

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'));

Upvotes: 1

Related Questions