Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Does express for node.js have a .request()

var http = require('http');

var options = {
    host: 'www.google.com',
    port: 80,
    path: '/upload',
    method: 'POST'
};

var req = http.request(options, function(res) {
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
    });
});

// write data to request body
req.write('data
');
req.write('data
');
req.end();
Comment

Send Request Express

yourproject/views/index.ejs

<html>
<head><title></title></head>
<body>

<form action="/" method="POST">
<input name="abc" />
<input type="submit" value="submit"/>
</form>
</body>
</html>

yourproject/routers/index.js


var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.post("/", async function(Req, res, next)
{
res.send(req.body.abc)

});

module.exports = router;
Comment

node js http request express

npm install request@2.81.0
Comment

PREVIOUS NEXT
Code Example
Javascript :: react query 
Javascript :: axios 
Javascript :: all jquery selectors 
Javascript :: random name 
Javascript :: double exclamation mark js 
Javascript :: Nodemailer Google Passport Oauth Strategy 
Javascript :: match if 
Javascript :: javascript get all instances of a class 
Javascript :: get vue-emoji-picker 
Javascript :: javascript reflect 
Javascript :: reducer react 
Javascript :: enable javascript chrome 
Javascript :: react js photo gallery 
Javascript :: 10 to the power of negative n 
Javascript :: passport middleware check if authenticated 
Javascript :: alert in react native 
Javascript :: node 
Javascript :: do while loop javascript 
Javascript :: react native time range picker 
Javascript :: how to change textContent in js 
Javascript :: scss variables in react 
Javascript :: metadata object ANGULAR 
Javascript :: node api with mongodb 
Javascript :: run only one test cypress 
Javascript :: nodejs cdn 
Javascript :: scrollintoview 
Javascript :: http error 406 
Javascript :: how to use hash in javascript 
Javascript :: req.header express.js 
Javascript :: jaascript loop 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =