When I run my code like this, the console shows an empty array. However when I use console.log(res.data) I get the expected json object of employees without a problem.
state = {
userList: [],
firstName: "",
lastName: "",
position: ""
};
loadUsers = () => {
API.getUsers()
.then(res =>
this.setState({ userList: res.data, firstName: "", lastName: "",
position: "" })
)
.then (console.log(this.state.userList))
.catch(err => console.log(err));
};
Either way the code is run I also get an Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () error message.