I can't reach the data.
MyApi.js
fetch('https://reqres.in/api/users?page=2')
.then(res => res.json())
.then((result) => {
UsersAPI.users.push(result.data)
});
const UsersAPI = {
users: [],
};
export default UsersAPI;
MyUsers.js
export default class MyUsers extends Component {
render() {
console.log(UsersAPI.users);
return (
<div></div>
) ....
console.log( UsersAPI.users[0] ) not working. How can I show data in the console. If my code is wrong you can make changes to my code