-
Notifications
You must be signed in to change notification settings - Fork 0
/
forwarder.js
32 lines (25 loc) · 890 Bytes
/
forwarder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express')
const bodyParser = require('body-parser')
const axios = require('axios')
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/forward', (req, res) => { // frontend
const URLParams = new URLSearchParams();
URLParams.append("temperature", req.body.temperature)
URLParams.append("sun", req.body.sun)
URLParams.append("humidity", req.body.humidity)
URLParams.append("water", req.body.water)
URLParams.append("ph", req.body.ph)
URLParams.append("pairing", req.body.pairing)
URLParams.append("identifier", req.body.identifier)
console.log(URLParams)
try {
axios.post("https://calebgj.io/plantAPI/sendPlantData", URLParams)
.then(function (response) {
console.log(response.data);
})
} catch {}
});
app.listen( 3001, () => {
console.log('server started at localhost:');
})