Chat freely about the open source Javascript projects for ESP8266

User avatar
By quackmore
#94404 you'll have to specify the content-type for body-parser to work
this example will work if you add an header with "Content-type: text/plain;" to the POST in your arduino code

Code: Select allconst express = require('express')
const bodyParser = require('body-parser')
const app = express()

app.use(bodyParser.text()) // body-parse will look for 'text' content

app.get('/', (req, res) => {
    res.send('hello world')
})

app.post('/', (req, res) => {
    console.log("post triggered")
    console.log(req.body)
    res.send('got it')
})

app.listen(3000, function () {
    console.log('Example app listening on port 3000!');
})