Created
February 22, 2017 18:48
-
-
Save bluzir/75b4e84e2243eddd7f6fd3c9e2f2635e 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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
var token = document.head.querySelector("[name=token]").content, | |
user = {}; | |
var Profile = React.createClass({ | |
render: function() { | |
return ( | |
<div className="profile__info"> | |
<h3>{user.first_name} {user.last_name}</h3> | |
<h4>{user.email}</h4> | |
</div> | |
); | |
} | |
}); | |
var App = React.createClass({ | |
render: function() { | |
return ( | |
<div className="app"> | |
<ol className="breadcrumb"> | |
<li>Профиль</li> | |
</ol> | |
<Profile data={user}/> | |
</div> | |
); | |
} | |
}); | |
fetch('/api/profile/?token=' + token) | |
.then( | |
function(response) { | |
response.json().then(function(data) { | |
user = data['users']; | |
ReactDOM.render( | |
<div className="col-md-6"><App /></div>, | |
document.getElementById('profile') | |
); | |
}); | |
} | |
) | |
.catch(function(err) { | |
console.log('Fetch Error :-S', err); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment