here is my code, please tell me if there is any error...........i am getting empty page with loading symbol as output
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
dataSource: null,
}
}
componentDidMount () {
return fetch('http://localhost/alfresco/s/api/task-instances?authority=user2&pooledTasks=true', {
method: 'get',
headers: new Headers({
username: "user2",
password: "password"
})
})
.then ( (response) => response.json() )
.then( (responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson.data,
})
})
.catch((error) => {
console.log(error)
});
}
render() {
if (this.state.isLoading) {
return (
<View style={styles.container}>
<ActivityIndicator />
</View>
)
} else {
let data = this.state.dataSource.map((val, key) => {
return <View key={key} style={styles.item}>
<Text>{val.title}</Text></View>
});
return (
<View style={styles.container}>
<Text>
{ id }
</Text>
</View>
);
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
});