Skip to content

Instantly share code, notes, and snippets.

@lmas3009
Last active January 31, 2021 16:14
Show Gist options
  • Save lmas3009/0cd38b7426b5263315cf4631b6e41e5e to your computer and use it in GitHub Desktop.
Save lmas3009/0cd38b7426b5263315cf4631b6e41e5e to your computer and use it in GitHub Desktop.
A Simple MERN Full Stack Application
import React, { useState, useEffect } from 'react';
import axios from 'axios'
function Main() {
const [data,setdata] = useState([])
useEffect(() => {
async function fetchData() {
const res = await axios.get("https://user-details-mern.herokuapp.com/details")
setdata(res.data)
}
fetchData()
})
return (
<div className="Main">
<table>
<tr>
<th>Name</th>
<th>FullName</th>
<th>Address</th>
<th>Phone Number</th>
<th>Email Id</th>
</tr>
{data.map((item) => (
<tr>
<td>{item.Name}</td>
<td>{item.FName}</td>
<td>{item.Address}</td>
<td>{item.PhonNo}</td>
<td>{item.Email}</td>
</tr>
))}
</table>
</div>
)
}
export default Main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment