Receiving json post in node

Skip to first unread message

Kieran Lambert

Jul 22, 2020, 2:00:53 AM7/22/20
to nodejs
Hi, i'm new to node js and trying to write something to receive a json post and then manipulate it.

I have created a server as such to listen over https to receive incoming requests,

const https = require("https"),
fs = require("fs"),
helmet = require("helmet");
express = require("express");

const options = {
key: fs.readFileSync("//Users/Documents/nodejs/pd_int/keys/server.key"),
cert: fs.readFileSync("/Users/Documents/nodejs/pd_int/keys/server.crt")

const app = express();

app.use(helmet()); // Add Helmet as a middleware to force https

app.use((req, res) => {
res.end("hello world\n");


https.createServer(options, app).listen(8080);

Not too sure however how to receive the post from the third party.

Any thoughts on how to ammend the above to receive the json post thus allowing me to further manipulate it with another piece of code I have ..? Appreciate any advice/assistance

Aug 3, 2020, 5:34:42 PM8/3/20
to nodejs
Enable the cors and the body-parser using app.use and body-parser and cors package from express.
Reply all
Reply to author
0 new messages