Added post router with simple console log of body
This commit is contained in:
17
server.js
17
server.js
@@ -7,16 +7,8 @@
|
|||||||
var express = require('express'); // call express
|
var express = require('express'); // call express
|
||||||
var app = express(); // define our app using express
|
var app = express(); // define our app using express
|
||||||
var bodyParser = require('body-parser');
|
var bodyParser = require('body-parser');
|
||||||
var fs = require('fs');
|
|
||||||
var https = require('https');
|
|
||||||
var sqlite3 = require('sqlite3').verbose();
|
var sqlite3 = require('sqlite3').verbose();
|
||||||
|
|
||||||
var options = {
|
|
||||||
key : fs.readFileSync('certificates/server.key'),
|
|
||||||
cert : fs.readFileSync('certificates/server.crt')
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// configure app to use bodyParser()
|
// configure app to use bodyParser()
|
||||||
// this will let us get the data from a POST
|
// this will let us get the data from a POST
|
||||||
@@ -53,6 +45,10 @@ router.get('/seasoned', function(req, res) {
|
|||||||
res.json({episode}); // this is where you get the return value
|
res.json({episode}); // this is where you get the return value
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/seasoned', function (req, res) {
|
||||||
|
console.log(req.body);
|
||||||
|
})
|
||||||
// more routes for our API will happen here
|
// more routes for our API will happen here
|
||||||
|
|
||||||
// REGISTER OUR ROUTES -------------------------------
|
// REGISTER OUR ROUTES -------------------------------
|
||||||
@@ -61,6 +57,5 @@ app.use('/api', router);
|
|||||||
|
|
||||||
// START THE SERVER
|
// START THE SERVER
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
https.createServer(options, app).listen(port, function () {
|
app.listen(port);
|
||||||
console.log('Magic happens on port ' + port);
|
console.log('Magic happens on port ' + port);
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user