Version 1.0.1 - Fix de WebMetrics et de l'édit utilisateur
All checks were successful
Neutral/pipeline/head This commit looks good

This commit is contained in:
2024-01-13 19:20:11 +01:00
parent 3484ff9ff7
commit 377c3310e4
6 changed files with 50 additions and 14 deletions

View File

@ -28,13 +28,17 @@ module.exports.getMetrics = function() {
var processed = 0
if(metrics.length == 0) {
resolve(metricsToReturn)
}
await metrics.forEach(async (metric) => {
// Try to connect to the metric server with the key in query params named "privatekey"
// If the connection is successful, we add the metric to the list of metrics to return
const url = `http://${metric.address}:${metric.port}/metrics?privatekey=${metric.key}`
const res = await fetch(url, {
const fet = await fetch(url, {
method: "GET",
headers: {
"Accept": "application/json",
@ -46,21 +50,33 @@ module.exports.getMetrics = function() {
if(res) {
metric.data = res
metricsToReturn.push(metric)
processed++
} else {
metric.data = "ERROR"
metricsToReturn.push(metric)
}
if(processed == metrics.length) {
resolve(metricsToReturn)
}
}).catch((err) => {
metric.data = "ERROR"
metricsToReturn.push(metric)
processed++
if(processed == metrics.length) {
resolve(metricsToReturn)
}
})
processed++
if(processed == metrics.length) {
resolve(metricsToReturn)
}
})
})