I am working for FCC, Twitch JSON API. I received the response of some datas via API, but it cannot load the data correctly.
Uncaught SyntaxError: Unexpected token ‘===’
Did I miss some parameters to get the data?
I am checking how the data shows, so the entire code is not finished yet.
const url = 'https://wind-bow.glitch.me/twitch-api/streams/'
const streamers = [ "freecodecamp", "ESL_SC2", "OgamingSC2", "cretetion", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas" ];
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
radio : [
{value:'All', name: 'All', checked: true},
{value:'ONLINE', name: 'ONLINE'},
{value:'OFFLINE', name: 'OFFLINE'}
]
}
}
componentDidMount() {
streamers.forEach(streamer => {
fetchJsonp(url + streamer + `?callback=?`)
.then(function(response) {
console.log("response", response)
return response.json()
}).then(function(json) {
console.log('parsed json', json)
}).catch(function(ex) {
console.log('parsing failed', ex)
})
})
};
render() {
const radio = this.state.radio;
const listItems = radio.map((r) =>
<label key={r.value.toString()}>
<input
type="radio"
name="select"
value={r.value}
checked={r.checked}
onChange={this.handleRadioClick} />
{r.name} <br />
</label>
);
return (
<div className='title'>
<h1>TWITCH STREAMERS</h1>
<form>{listItems}</form>
</div>
)
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);