app.post('/process_post', urlencodedParser, (req, res) => { // należy utworzyć nowy obiekt const newWeather = { location: req.body.location, temperature: req.body.temperature, humidity: req.body.humidity, pressure: req.body.pressure }; // pobrać aktualne dane z pogodą const weather = JSON.parse(fs.readFileSync("weather.json")); // dodać do nich nową pogodę weather.push(newWeather); // i napisać zapisać dane do pliku fs.writeFileSync("weather.json", JSON.stringify(weather)); });
--