Last active
November 16, 2019 19:28
-
-
Save MustakTalukder/f1ba453075a76f9c8cb175fcd44c29e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { useState, useEffect } from 'react'; | |
| function ContactsList(props) { | |
| const [contactList, setcontactList] = useState([]); | |
| const url = 'http://todorestapi.test' | |
| const init = async () => { | |
| const response = await fetch(url + '/api/contact/all'); | |
| const json = await response.json() | |
| setcontactList(json) | |
| // console.log(typeof(json.data)) | |
| // json.data.forEach(el => { | |
| // console.log(el); | |
| // }); | |
| console.log('init useEffect') | |
| } | |
| useEffect(() => { | |
| init() | |
| }, []) | |
| return ( | |
| <div> | |
| { | |
| // JSON.stringify(contactList.data) | |
| // contactList.data.map((contact, i) => ( | |
| // <h1>{contact.email}</h1> | |
| // )) | |
| console.log('return div') | |
| } | |
| {/* <table className="table table-dark"> | |
| <thead> | |
| <tr> | |
| <th scope="col">#</th> | |
| <th scope="col">Name</th> | |
| <th scope="col">Email</th> | |
| <th scope="col">Contact</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| { | |
| contactList.data.forEach(contact => ( | |
| <tr> | |
| <th scope="row">2</th> | |
| <td>{contact.user_name}</td> | |
| <td>{contact.email}</td> | |
| <td>{contact.contact_number}</td> | |
| </tr> | |
| )) | |
| } | |
| </tbody> | |
| </table> */} | |
| </div> | |
| ); | |
| } | |
| export default ContactsList; |
raikusy
commented
Nov 16, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment