Thursday 17 December 2015

Really easy: why my code don't execute POST method (express)?

I'm stuck with this so bad that I'm almost pray for your help, folks. This code is running succesfully, but POST method just don't working at all (console.log('Hello POST'); logging nothing, for example).var express = require('express'); var app = express(); // This responds with "Hello World" on the homepage app.get('/', function (req, res) { console.log("Got a GET request for the homepage"); res.send('Hello GET'); }) // This responds a POST request for the homepage app.post('/', function (req, res) { console.log("Got a POST request for the homepage"); res.send('Hello POST'); }) var server = app.listen(8081, function () { var host = server.address().address var port = server.address().port console.log("Example app listening at http://%s:%s", host, port) })

Submitted December 17, 2015 at 09:33PM by GodOfTheMetal

No comments:

Post a Comment