I made a request in a URL via Fetch, however it returns an error when I request json mapping, does anyone know how to solve it?
I've hidden the URL because it's private.
import React, { Component } from 'react';
class App extends Component {
constructor(props){
super(props);
this.state = {
items:[],
isLoaded: false,
}
}
componentDidMount(){
fetch('***')
.then(res => res.json())
.then(json => {
this.setState({
isLoaded: true,
items : json,
})
});
}
render() {
var{isLoaded, items} = this.state;
if(!isLoaded){
return <div>Loading..</div>
}
else{
return (
<div className="App">
<ul>
{items.map(item => (
<li key = {item.id}>
Name : {item.name} | {item.name}
</li>
))};
</ul>
</div>
);
}
}
}
export default App;