diff --git a/index.js b/index.js index 601f5e3d9315baf3836bde42fdc6596446a69cb5..88731afc028b2c843c9d0b46734cea56aa7c578d 100644 --- a/index.js +++ b/index.js @@ -83,9 +83,11 @@ app.post('/am-i-ok/:deviceID', (req, res) => { console.log('Sent JSON:', responseToSend); }); -app.post('/json/:deviceID', (req, res) => { +app.post('/json/:deviceID/:f_n', (req, res) => { const deviceID = req.params.deviceID; + const f_n = req.params.f_n; console.log(`Json incoming form: ${deviceID}`) + console.log(`Json incoming form: ${f_n}`) let responseToSend const measurementsFolderPath = path.join(__dirname, 'measurements', deviceID); @@ -98,13 +100,13 @@ app.post('/json/:deviceID', (req, res) => { // Get filename from request body console.log("The body of the request is:") console.log(req.body) - console.log("The paramteres are:") + console.log("The parameters are:") console.log(req.params) const { filename, ...jsonData } = req.body; - console.log("The filename shold be:", filename) + console.log(`The filename should be: ${filename}`) // Generate unique filename if not provided - const fileName = filename || deviceID + '.json'; + const fileName = f_n || deviceID + '.json'; // Path to save the file const filePath = path.join(measurementsFolderPath, fileName);