-
-
Save AHaydar/fec3eeb3bfc4a8ef0c8a69e9014fec70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import CompanyDetails from './CompanyDetails'; | |
const App = () => { | |
const url = | |
'https://nfc079xjo3.execute-api.us-east-1.amazonaws.com/Prod/companies'; | |
const [companies, setCompanies] = useState([]); | |
useEffect(() => { | |
fetch(url) | |
.then((response) => response.json()) | |
.then((data) => { | |
setCompanies(data); | |
}); | |
}, []); | |
const companiesList = companies.map((company) => ( | |
<CompanyDetails | |
key={company.CompanyId} | |
companyId={company.CompanyId} | |
companyName={company.Details.name} | |
/> | |
)); | |
return ( | |
<> | |
Publicly listed companies: | |
<ul>{companiesList}</ul> | |
</> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment