I'm having some issues understanding why I'm getting a compile warning on this piece of my react code
fetch('/users')
.then(res => res.json())
.then(data => {
data.map(users => {
console.log(users);
});
});
The warning I'm getting is Expected to return a value in arrow function array-callback-return
However I'm still get the json object values from my /users
, and they are printed to the console individually. The object is:
{
id: 1,
username: "Foo"
}, {
id: 2,
username: "Bar"
}
Am I missing a return statement, or am I missing something with how map
returns values after a .then()
? I'm unclear on why the compile warning would appear at all.