Last active
August 22, 2018 09:31
-
-
Save seppestas/af157ebd7309517d1c294ea4db24628e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', './mac-address', true); | |
var formData = new FormData(); | |
formData.append('mac-address', mac); | |
xhr.send(formData); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.post('/mac-address', function(req, res) { | |
// TODO: check if valid mac | |
console.log(req); | |
console.log(req.body); | |
june_mac = req.body; | |
if (june_peripheral !== null) { | |
june_peripheral.disconnect(function(error) { | |
if (error !== null) { | |
res.status(500); | |
res.send(error); | |
console.log('Failed to diconnect'); | |
} else { | |
res.send('ok'); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment