Home > OS >  Data not showing React Axios
Data not showing React Axios

Time:08-17

I am trying to get data using axios but it doesn't seem to load onto the page. I have used the link in postman and retrieves all the data so I assume the get request from the server is fine but when used in the jsx file it shows no data here is my jsx file

index.js


import React from "react";
import { useState, useEffect } from "react";

import axios from 'axios'

export default function App() {
    const client = axios.create({
        baseURL: "http://localhost:8080/api/getUser" 
      });
      const [users, setPosts] = useState([]);

      useEffect(() => {
         client.get('?_limit=10').then((response) => {
            setPosts(response.data);
         });
      }, []);

  return (
    <div className="app">
    <h2>All Users            
  • Related