diff --git a/src/TopBar.js b/src/TopBar.js
index d6e3f4a..e44284b 100644
--- a/src/TopBar.js
+++ b/src/TopBar.js
@@ -16,12 +16,12 @@ class TopBar extends Component {
state = {
query: ''
};
- handleChange(event) {
+ handleChange = event => {
this.setState({
query: event.target.value
});
}
- handleSubmit(event) {
+ handleSubmit = event => {
event.preventDefault();
event.target.reset();
this.props.history.push('/search/' + this.state.query);
diff --git a/src/areainfo/Suggestion.js b/src/areainfo/Suggestion.js
index ac0d71d..66c6216 100644
--- a/src/areainfo/Suggestion.js
+++ b/src/areainfo/Suggestion.js
@@ -4,6 +4,8 @@ import { Row, Col, Button, Collapse } from 'react-bootstrap';
import { Switch, Route } from 'react-router';
import Random from '../reccomenders/Random';
import Related from '../reccomenders/Related';
+import Search from '../reccomenders/Search';
+
// and so on..
class Suggestion extends Component {
@@ -43,7 +45,8 @@ class Suggestion extends Component {
*/}
-
+
+
{/* lasciare questo per ultimo */}
@@ -54,8 +57,4 @@ class Suggestion extends Component {
}
}
-Suggestion.propTypes = {
-
-};
-
export default Suggestion;
\ No newline at end of file
diff --git a/src/reccomenders/Search.js b/src/reccomenders/Search.js
new file mode 100644
index 0000000..a84c3df
--- /dev/null
+++ b/src/reccomenders/Search.js
@@ -0,0 +1,61 @@
+import React from 'react';
+import axios from 'axios';
+
+class Search extends React.Component {
+
+ state = {
+ query: '',
+ res: null
+ }
+
+ static getDerivedStateFromProps(nextProps, prevState) {
+ if (nextProps.match.params.query !== prevState.query)
+ return { query: nextProps.match.params.query };
+ return null;
+ }
+
+ componentDidMount() {
+ this.youtubeSearch();
+ }
+
+ // shouldComponentUpdate(nextProps, nextState) {
+
+ // }
+
+ // componentDidUpdate(prevProps, prevState) {
+
+ // }
+
+ // componentWillUnmount() {
+
+ // }
+
+ youtubeSearch() {
+ axios.get('https://www.googleapis.com/youtube/v3/search', { //Richiesta per ottenere i commenti del video
+ params: {
+ 'part': 'snippet',
+ 'q': this.state.query,
+ 'videoEmbeddable': 'true',
+ 'type': 'video',
+ 'maxResults': 30,
+ 'topicId': '/m/04rlf, /m/02jjt',
+ 'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
+ }
+ }).then(
+ res => {
+ console.log(res.data)
+ },
+ error => {console.error(error)}
+ )
+ }
+
+ render() {
+ return (
+
+ {this.state.query} keyword
+
+ );
+ }
+}
+
+export default Search;
\ No newline at end of file