INNER CODE UNIT · JavaScript
getSensors
PatrickHallek/automated-irrigation-system · src/Main.js:19
const getSensors = () => {
fetch(`${process.env.REACT_APP_BACKEND_URL}/sensors`)
.then(res => res.json())
.then(
async (sensors) => {
setSensors(sensors)
setSensorInFocus(sensors[0])
},
(error) => {
console.log(`Coudn't fetch data. Error: ${error}`)
}
)
}
return (
<div>
<Header />
<div className="main">