mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 10:30:17 +01:00
Syncronisation de la page d'accueil avec l'api
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { api } from "../config/reviewsApi";
|
||||
|
||||
export default function useStats(limit, interval) {
|
||||
@@ -7,7 +7,7 @@ export default function useStats(limit, interval) {
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
async function fetchData(limit, interval) {
|
||||
const response = await fetch("http://" + api.HOST + `/get_stats?interval=${interval}&limit=${limit}`)
|
||||
const response = await fetch("http://" + api.HOST + `/borne/get_stats?interval=${interval}&limit=${limit}`)
|
||||
if(response.ok) {
|
||||
const data = await response.json();
|
||||
setStats(data);
|
||||
@@ -20,7 +20,7 @@ export default function useStats(limit, interval) {
|
||||
|
||||
useEffect(() => {
|
||||
fetchData(limit, interval);
|
||||
})
|
||||
}, [])
|
||||
|
||||
return {stats, loading, error};
|
||||
}
|
||||
Reference in New Issue
Block a user