I'm writing a React app to pull specific data from an API done through search (forms), storing it and manipulating it using filters and what not. So far I have pulled the data and displayed it, but I just cannot work out how to store it using state so that I can access it without having to do an entirely new data pull.
So far I have tried returning the API data to be stored in a list locally inside the function, but then I have zero access to manipulate it moving forward. I think I need 'list' with name and age stored in state, and then accessed, but I just can't work out how to do it. Any help would be greatly appreciated.
function dataPull(param) {
const list = [
{ name: '', age: ''}
]
const URLbase = "https://APIexample.com";
const query = URLbase + param;
const URL = URLbase + param;
fetch(URL)
.then(fnc(res) {
let text = document.getElementById('textSpot');
res.map(res => (
<list key={res.name} age={res.age} />
));
text.innerHTML = res;
}