I'm having doubts about how I can iterate through the offices array and pass its elements as arguments of the getEmployeePerService function:

function ServiceData() {
    const [numberEmployee, setNumberEmployee] = useState(0);
    const [office, setOffice] = useState([]);
    let offices;

    async function getEmployeePerService(service) {
        const response = await api.get(`/api/numberEmployee/${service}`);
    async function getOffices() {
        const response = await api.get(`/api/getOffice`);

        offices = office.filter((este, i) => office.indexOf(este) === i);

    useEffect(() => {

    }, [numberEmployee]);
  { office.map((some_data) => (
    <SomeElement key={some_data.id}>{ /* render the data */ }</SomeElement>
1 Like

how can i pass it inside getEmployee method that i have called inside useEffet()???

obs: offices is just a array of services
example: const offices=[‘doctor’, ‘nurse’, ‘footballer’,]

Are you saying you want to fetch multiple times using the array elements as arguments to fetch?

Google: fetch promise.all

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.