Skip to content

Instantly share code, notes, and snippets.

@anthonybrown
Last active November 2, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybrown/5d5d067718161a4a757c55329714be46 to your computer and use it in GitHub Desktop.
Save anthonybrown/5d5d067718161a4a757c55329714be46 to your computer and use it in GitHub Desktop.
Trying to display data
import React, { Component } from 'react'
import axios from 'axios';
import cookie from 'react-cookie';
import { Modal,Button } from 'react-bootstrap'
import { API_URL, CLIENT_ROOT_URL, errorHandler } from '../../actions/index';
class Professor extends Component {
constructor(props) {
super(props)
this.state = {}
}
componentDidMount () {
const authorization = "Bearer"+cookie.load('token').replace("JWT","")
axios.get(`${API_URL}/core/me`, {
headers: { 'Authorization': authorization }
})
.then(response => {
this.setState({classrooms:response.data})
})
.catch((error) => {
console.log("error",error)
})
}
render () {
return (
<div className='container'>
<div className='jumbotron'>
<h1>Professor Page</h1>
<p>Welcome to the professor page.</p>
</div>
<div className='container'>
<div className='well'>
<pre>{JSON.stringify(this.state, null, ' ')}</pre>
</div>
</div>
</div>
)
}
}
export default Professor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment