import React, { useState, useEffect, useRef } from 'react'; import { Link } from 'react-router-dom'; import { Navbar, Nav } from 'react-bootstrap'; import axios from 'axios'; import catchErrors from '../utils/catchErrors'; function SubNav() { const [categorysDiv, setCategorysDiv] = useState([]) const [error, setError] = useState('') useEffect(async () => { try { const response = await axios.get('/api/categorys') let list = [] Object.keys(response.data[0]).forEach((ele) => { const url = ele.toLowerCase() list.push( {ele} ) }) setCategorysDiv(list) } catch (error) { catchErrors(error, setError) } }, []) return ( ) } export default SubNav