Data is not getting fetched from db.json file

App.js

import React, { useState, useEffect } from 'react';
import api from '../src/api/List';
import DisplayList from './displayList';
import './App.css';

function App() {
  const [contacts,setContacts] = useState([]);
  
  useEffect(()=>{
       api.get('api/List')
    .then((response)=>{
      return setContacts(response.data);
    })
    .catch((error)=>{
      console.log(error);
    })
  },[])
  return (
    <div className="App">
      <DisplayList  contacts={contacts}/>
    </div>
  );
}

export default App;

The local host url where data is placed !!

local host data:

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