I'd like to filter the data fetched from the api by names that include the letter "A" and then place only the employee names in a div. I've been trying for a while but can't seem to get it to work. How can I achieve this?
import React, { useState, useEffect } from "react";
export default function App() {
const [data, setData] = useState([]);
const [input, setInput] = useState("");
const [suggestions, setSuggestions] = useState([]);
useEffect(() => {
fetch("https://dummy.restapiexample.com/api/v1/employees")
.then((response) => response.json())
.then((result) => setData(result.data));
}, []);
const info = data.map((employee) => {
return <div> {employee.employee_name} </div>;
});
const handleChange = (e) => {
setInput(e.target.value);
};
return (
<div className="App">
<form>
{" "}
Enter your Search:
<input type="text" onChange={handleChange}></input>
</form>
<div className="suggestions-div">{info}</div>
</div>
);
}
<input />?