From fed07d5ea6134555aa0609d2bc251fb7277373db Mon Sep 17 00:00:00 2001 From: Chaadrack Date: Sun, 22 Jan 2023 21:18:04 -0500 Subject: [PATCH] made changes to file --- CD220Labs/react-apps/src/App.js | 47 +++++++++++++++++++++++++++---- CD220Labs/react-apps/src/index.js | 2 +- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CD220Labs/react-apps/src/App.js b/CD220Labs/react-apps/src/App.js index c107a2439..a7140daee 100644 --- a/CD220Labs/react-apps/src/App.js +++ b/CD220Labs/react-apps/src/App.js @@ -1,9 +1,44 @@ -function App() { - return ( -
- Hello World! +import React from 'react'; +import axios from 'axios'; + +class App extends React.Component { + state = { APIlist:[] } + + componentDidMount() { + let url = "https://api.publicapis.org/entries?category=Animals"; + axios({ + method: 'get', + url: url, + responseType: 'json' + }).then(resp => { + let listOfEntries = resp.data.entries; + let listOfEntriesAsArray = Object.entries(listOfEntries); + let entryDetails = listOfEntriesAsArray.map((entryDetail)=>{ + return
  • {entryDetail[1]["API"]} + ------- {entryDetail[1]["Link"]}
  • + }) + this.setState({APIlist:}) + }) + .catch(err => { + console.log(err.toString()) + }); + } + + render() { + const colorStyle = { color:this.props.color,fontSize:this.props.size+"px"} + return ( +
    +

    APIs List

    +
    + +
    + { + this.state.APIlist + } +
    - ); + ); + } } -export default App; +export default App; \ No newline at end of file diff --git a/CD220Labs/react-apps/src/index.js b/CD220Labs/react-apps/src/index.js index 7173ce536..14c824c34 100644 --- a/CD220Labs/react-apps/src/index.js +++ b/CD220Labs/react-apps/src/index.js @@ -4,7 +4,7 @@ import App from './App'; ReactDOM.render( - + , document.getElementById('root') ); \ No newline at end of file