2022-11-08 00:42:15 -05:00

35 lines
850 B
JavaScript

import { useEffect } from "react";
import { useState } from "react";
import InvoiceList from "../components/InvoiceList";
const Invoices = () => {
const [invoices, setInvoices] = useState([]);
useEffect(() => {
fetch(`https://localhost:7292/api/Invoice?all=true`, {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(async (response) => {
if (response.ok) {
var json = await response.json();
console.log(json);
setInvoices(json);
}
else{
console.log("Erreur lors de la requête des invoices");
}
});
}, []);
return (
<>
<InvoiceList
invoices={invoices}
/>
</>
);
}
export default Invoices