I am developing a mobile app in react- native as a beginner. I have a little problem while using react-native. let me explain it in detail, what I am trying to do is fetching data from Restful api and assign this data to array in react. Below is my code to fill array data.
function getMoviesFromApiAsync() {
return fetch('http://localhost:8080/JweSecurityExample/rest/security/retrieveItems')
.then((response) => response.json())
.then((responseJson) => {
return JSON.stringify(responseJson)
})
.catch((error) => {
console.error(error);
});
}
const initialState = {
data: getMoviesFromApiAsync();
};
export default (state = initialState,action ) => {
return state;
};
Above is all my .Js file and it does not has class declaration.
Any help ??