Skip to content

Instantly share code, notes, and snippets.

@jmercedes
Created September 10, 2018 18:59
Show Gist options
  • Save jmercedes/7201df687af58c413dddfef867448910 to your computer and use it in GitHub Desktop.
Save jmercedes/7201df687af58c413dddfef867448910 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
class PatientProfile extends Component {
state = {
paciente: {}
}
componentDidMount(){
fetch('https://jsonplaceholder.typicode.com/posts?userId=1')
.then( (res) => res.json() )
.then( (data) => {
this.setState({ paciente: data
})
})
}
render(){
const { paciente } = this.state
console.log(this.state.paciente)
return (
<div>
<h1>Perfil</h1>
<h1>{paciente.title}</h1>
</div>
)
}
}
export default PatientProfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment