function reqListener() {
var data = JSON.parse(this.responseText);
students = data.students;
console.log(data.students);
}
function reqError(err) {
console.log('Error :-S', err);
}
let students = [];
const RenderStudent = React.createClass({
getInitialState: function () {
return {
students: students,
};
},
handleRefresh: function () {
this.setState({
students: students
});
console.log("Students json: ");
console.log(students);
},
componentDidMount: function(){
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.onerror = reqError;
oReq.open('get', 'http://devbiz.s-host.net//personal-office/students/get-all-data-about-students', true);
oReq.send();
this.setState({
students: students
});
},
render: function () {
let onEditStudent = this.props.onEdit;
return (
<div>
<Refresh handleRefresh={this.handleRefresh}/>
{
this.state.students.map(function (val) {
return <Student
key={val.id}
firstName={val.name}
secondName={val.surname}
telephone={val.telephone}
onEditStudent={onEditStudent.bind(null, val)}
/>
})
}
<nav className="pag">
<PaginationPanel handleRefresh={this.handleRefresh}/>
</nav>
</div>
);
}
});
let students = [];
getInitialState: function () {
return {
students: students,
};
},
componentDidMount: function(){
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.onerror = reqError;
oReq.open('get', 'http://devbiz.net//personal-office/students, true');
oReq.send();
this.setState({
students: students
});
собственно тоже что и присылается в ответе.