I have this fetch
statement that returns 19 building names, but I only want 10; the following is what I attempted, but I still get 19 building names.
fetchBuildings(energyProgramId) {
fetch(`http://localhost:1001/api/energyprograms/${energyProgramId}/buildings/?results=10`)
.then(res => res.json())
.then(json => {
this.setState({
isLoaded: true,
buildings: json,
})
});
}
Is there something extra I need to add?
results=10
. You should consult the documentation for the api framework you are using. Or you could add information about the backend and tag this question with the relevant tag.results=10
. We have to see the server side code for this. From what you're saying you're not returning 10.