Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentDidMount() {
- fetch("http://localhost:8001/testing", {
- method: 'GET',
- headers: {
- 'Access-Control-Allow-Origin':'*',
- 'Access-Control-Allow-Methods':"GET, POST, PUT, DELETE,OPTIONS",
- 'Content-Type': '"application/json'
- }
- }).then(response => {
- response.json()
- .then(data => {
- console.log(data);
- let legoParts = data.map((legoPart) => {
- return (
- <div key ={legoPart.id}>
- {legoPart.name}
- </div>
- )
- })
- this.setState({legoParts: legoParts})
- }
- );
- })
- .catch(function(err) {
- console.log("i failed");
- });
- }
- (2) [{…}, {…}]
- 0:{id: 1, piece: "tree", type: "garden"}
- 1: {id:2 piece:"hat" type: "clothes"}
- __proto__:Object
- length:2
- __proto__:Array(0)
Add Comment
Please, Sign In to add comment