i am using create-react-app to build a simple gallery based on reddit API using reddit.js
used "npm install --save reddit.js" in the "C:....\reddit-gallery"
wrote some basic code, and then, when using npm start to run it, i keep getting:
Failed to compile.
Error in ./src/App.js
C:....\reddit-gallery\src\App.js
18:9 error 'reddit' is not defined no-undef
while coding it is recognizing the library, but when using npm it does not recognize any code from that library
the code:
import 'reddit.js';
class App extends Component {
constructor(props){
super(props);
this.state = {};
this.loadSubreddit = this.loadSubreddit.bind(this);
}
loadSubreddit(subre){
reddit.hot(subre)
.then(response => {
return response.json();
}).then(json => {
console.log(json)
})
}
componentWillMount() {
console.log('comp is mounting');
this.loadSubreddit('cats');
}
via Ben Porat
No comments:
Post a Comment