You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
672 B
26 lines
672 B
import { sub } from 'date-fns'
|
|
import { formatDate } from './metrics';
|
|
|
|
|
|
export const getLogs = async function ({
|
|
start = sub(new Date(), { hours: 12 }),
|
|
end = new Date(),
|
|
filter = ""
|
|
} = {}) {
|
|
try {
|
|
const data = await fetch(`http://localhost:8080/api/v1/metrics/log?filter=${filter}`, {
|
|
"method": "GET",
|
|
"headers": { "Accept": "application/json" }
|
|
});
|
|
|
|
const { success, payload } = await data.json();
|
|
if (success) {
|
|
return { payload, start, end, filter };
|
|
}
|
|
return { error: payload };
|
|
} catch (error) {
|
|
console.error(error);
|
|
return { error };
|
|
}
|
|
}
|