I'm using ReactJS to run my Front and ExpressJS to run my API. So at my ReactJS App, I want to show only array id: 8 to id: 12 for example, because this way I have the code it prints all the arrays.
import React, {Component} from 'react';
import AppHeader from './AppHeader.js';
import './AppHomepage.css';
import {Link} from 'react-router-dom';
class AppHomepage extends Component {
constructor(props) {
super(props);
this.state = {
Book: []
}
}
componentDidMount() {
this.getList();
}
getList = () => {
fetch('/api')
.then(res => res.json())
.then(Book => this.setState({Book}))
}
render() {
return (
<div>
<AppHeader />
<div className="hpcontainer">
<div className="hpholder">
<h1 className="hptitle">Kuran Shqip</h1>
<p className="hptxt">Një projekt sadaka kushtuar lexuesve të Kuranit famëlartë.</p>
<div className="hpsurahlist">
{this.state.Book.map(Book =>
<Link to={Book.path} className="hpsurah">
<p className="hpid">{Book.id}</p>
<div>
<h2 className="hpsurahsq">{Book.surah}</h2>
<h1 className="hpsurahen">{Book.surahsq}</h1>
<h3 className="hpnumber">{Book.verses}</h3>
</div>
</Link>)}
</div>
</div>
</div>
</div>
)
}
}
export default AppHomepage;
I tried this from someone In the comments but didn't work
{this.state.Book.filter(Book => Book.id >= 8 && Book.id <= 12).map(Book =>
<Link to={Book.path} className="hpsurah">
<p className="hpid">{Book.id}</p>
<div>
<h2 className="hpsurahsq">{Book.surah}</h2>
<h1 className="hpsurahen">{Book.surahsq}</h1>
<h3 className="hpnumber">{Book.verses}</h3>
</div>
</Link>)}
{Book.id}
{Book.surah}
{Book.surahsq}
{Book.verses}