TinyForest system front-end written with ReactJS
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.
 
 
 

47 lines
1.2 KiB

import React, { useState, useEffect } from 'react';
const LogParser = () => {
const [sensor, setSensor] = useState([]);
const [systemfile, setSystemfile] = useState([]);
const [jsoncheck, setJsoncheck] = useState([]);
useEffect(() => {
fetchSensor();
fetchSystemfile();
fetchJsoncheck();
}, [])
const fetchSensor = () => {
fetch('../tinyforest.log.json')
.then((res) => res.json())
.then(data => setSensor(data.sensor.msg))
.catch(err => console.error(err))
}
const fetchSystemfile = () => {
fetch('../tinyforest.log.json')
.then((res) => res.json())
.then(data => setSystemfile(data.system_file.msg))
.catch(err => console.error(err))
}
const fetchJsoncheck = () => {
fetch('../tinyforest.log.json')
.then((res) => res.json())
.then(data => setJsoncheck(data.json_check.msg))
.catch(err => console.error(err))
}
console.log(sensor)
console.log(jsoncheck)
console.log(systemfile)
return (
<div>
<p>{sensor.name}: {sensor.description}</p>
<p>{jsoncheck.description}</p>
</div>
);
};
export default LogParser;