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 [categoriesDiv, setCategoriesDiv] = useState([]) const [error, setError] = useState('') useEffect(async () => { try { const response = await axios.get('/api/categories/main') let list = [] Object.keys(response.data[0]).forEach((ele) => { const url = ele.toLowerCase() list.push( {ele} ) }) setCategoriesDiv(list) } catch (error) { catchErrors(error, setError) } }, []) return ( ) } export default SubNav