I would like to destructurize a json
to get the name, email and address of the api, but only print the json on the console,
does not work correctly <p>{props.nombre}</p>
, what is my error or how can I get those values?
import React from 'react';
class AppRestaurantes extends React.Component {
constructor() {
super();
this.state={
contactos:[],
usuarios:[],
nombre:'',
telefono:''
}
}
componentDidMount() {
this.unaPromesa();
}
unaPromesa = () => {
fetch('https://api.myjson.com/bins/1femoq')
.then(res => res.json() )
.then(data => {
console.log(data);
this.setState({
usuarios:data,
nombre:data.name
})
})
}
render(){
return(<div className='viajes-contenedor'>
<h2>Encuentra tu Restaurante Favorito</h2>
<ListaRestaurantes
nombre={this.state.nombre}
usuarios={this.state.usuarios}
/>
</div>);
}
}
export default AppRestaurantes;
const ListaRestaurantes = (props) => {
return(<div>
{props.usuarios.map((item, i)=>(
<div key={i}>
<p>{props.nombre}</p>
</div>
))}
</div>
)
}