Timk10
Timk10

Reputation: 191

How to display the URL data in a POST Request using Express, Javascript & Handlebars?

How would I go about utilizing a POST request to display the URL data like a GET request? For example I'm trying to have the URL "http://localhost:8000/requestPost?hello=goodbye&numbers=123" print the following list -

How would I go about getting access to the URL variables with a POST? I'm using Express & Handlebars.

Upvotes: 1

Views: 85

Answers (1)

klugjo
klugjo

Reputation: 20875

You would do it the same way as you would for a get request:

var express = require('express');
var app = express();

app.post('/requestPost', function(req, res){
  res.send('hello: ' + req.query.hello + ' numbers: ' + req.query.numbers);
});

app.listen(3000);

Upvotes: 2

Related Questions