node.js - Node Express - empty query after form submit -


i pars url after form submit. have simple form:

form(method='post', action='/recipe/create')   hr     div       div.input.text         label(for='recipetitle') tytuł przepisu:         input(type='text', name='recipetitle', id='recipetitle')       div.input.text         label(for='photofilename') nazwa zdjęcia:         input(type='text', name='photofilename', id='photofilename') 

after submit code executed.

exports.create = function(req, res){    var url = require('url');     var url_parts = url.parse(req.url, true);       console.log(url_parts); 

my question why console shows empty query

{ protocol: null,   slashes: null,   auth: null,   host: null,   port: null,   hostname: null,   hash: null,   search: '',   query: {},   pathname: '/recipe/create',   path: '/recipe/create',   href: '/recipe/create' } 

this happens because you're posting url doesn't have query string - /recipe/create.

also, seem using express, give current query string parsed:

// /search?q=tobi+ferret req.query.q // => "tobi ferret"  // /shoes?order=desc&shoe[color]=blue&shoe[type]=converse req.query.order // => "desc"  req.query.shoe.color // => "blue"  req.query.shoe.type // => "converse" 

reference


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -