Archived
bobbe malle
This commit is contained in:
+16
-14
@@ -11,22 +11,23 @@ class Wikipedia extends Component {
|
|||||||
error: null,
|
error: null,
|
||||||
isLoaded: false
|
isLoaded: false
|
||||||
};
|
};
|
||||||
this.getWikiBox = this.getWikiBox.bind(this);
|
this.getWikiBox = this.getWikiBox.bind(this);
|
||||||
this.raffina = this.raffina.bind(this);
|
this.raffina = this.raffina.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWikiBox(name){
|
getWikiBox(name) {
|
||||||
wikijs()
|
wikijs()
|
||||||
.page(name)
|
.page(name)
|
||||||
.then(page => page.fullInfo())
|
.then(page => page.fullInfo())
|
||||||
.then(infobox => console.log('infobox', infobox)
|
.then(
|
||||||
|
infobox => console.log('infobox', infobox)
|
||||||
//this.setState({ infobox })
|
//this.setState({ infobox })
|
||||||
);
|
);
|
||||||
//console.log('infobox', this.state.infobox)
|
//console.log('infobox', this.state.infobox)
|
||||||
}
|
}
|
||||||
|
|
||||||
raffina(results){
|
raffina(results) {
|
||||||
console.log('raffina',results);
|
console.log('raffina', results);
|
||||||
return results[0];
|
return results[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,20 +36,25 @@ this.raffina = this.raffina.bind(this);
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
wikijs().find(this.props.query, this.raffina).then(data => {
|
wikijs()
|
||||||
|
.find(this.props.query, this.raffina)
|
||||||
|
.then(
|
||||||
|
data => {
|
||||||
this.setState({
|
this.setState({
|
||||||
data,
|
data,
|
||||||
isLoaded: true
|
isLoaded: true
|
||||||
});
|
});
|
||||||
console.log(data.html());
|
console.log(data.html());
|
||||||
//this.getWikiBox(data.results[0]);
|
//this.getWikiBox(data.results[0]);
|
||||||
}, error => {
|
},
|
||||||
|
error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
error
|
error
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// componentWillReceiveProps(nextProps) {
|
// componentWillReceiveProps(nextProps) {
|
||||||
@@ -74,11 +80,7 @@ this.raffina = this.raffina.bind(this);
|
|||||||
render() {
|
render() {
|
||||||
const { data, error, isLoaded } = this.state;
|
const { data, error, isLoaded } = this.state;
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return <React.Fragment>Error: {error.message}</React.Fragment>;
|
||||||
<React.Fragment>
|
|
||||||
Error: {error.message} -- Cannot get {error.config.url}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
} else if (!isLoaded) {
|
} else if (!isLoaded) {
|
||||||
return <React.Fragment>Loading...</React.Fragment>;
|
return <React.Fragment>Loading...</React.Fragment>;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user