I'm trying to create a simple app the retrieves data from a facebook demo api and displays them with react native.
This is my code (for index.android.js) :
import React, { Component } from 'react';
import { AppRegistry, Text , View } from 'react-native';
class AwesomeProject extends Component{
constructor(props){
super(props);
this.state = {
movies: []
}
};
componentWillMount(){
this.getMoviesFromApi().then((res) => {
movies: res.movies;
});
}
async function getMoviesFromApi() {
try {
let response = await fetch('https://facebook.github.io/react-native/movies.json');
let responseJson = await response.json();
return responseJson.movies;
} catch(error) {
console.error(error);
}
}
render() {
return(
<Text>
{this.state.movies}
</Text>
);
}
}
AppRegistry.registerComponent('AwesomeProject',() => AwesomeProject);
But it keeps giving me this error:
Unexcepted token, excpected ( (28:18) index.android.js:23:18