0

import React, { useEffect, useState } from 'react'
import './MainMenu.css'
import axios from 'axios'
import { api } from "../config";




function MainMenu() {
    const [items, setItems] = useState([]);

    useEffect(()=>{

        const FecthItems = async()=>{
           //const result = await axios.get( api +"/item/all");
           const result = await axios.get('${api}/item/all');
           //console.log(result);
           setItems(result.data);
        };
           FecthItems();
    }, []);

when its working with this -- const result = await axios.get( api +"/item/all"); its not working with --- const result = await axios.get('${api}/item/all');

so please can i know why its not working with ${api}

Sudesh
  • 1
  • 2
  • [Template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) require back-ticks ` not single quotes. – Andy Dec 03 '22 at 07:01

0 Answers0