Answers for "express get query parameters"

15

express get query params from url

GET /something?color1=red&color2=blue

app.get('/something', (req, res) => {
    req.query.color1 === 'red'  // true
    req.query.color2 === 'blue' // true
})
Posted by: Guest on July-03-2020
2

node.js express post query string

const express = require('express');
const bodyParser = require('body-parser');

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));

// POST /somepost/?name=somename
app.post('/somepost', (req, res) => {
    console.log('Name:', req.query.name);
    res.status(200);
});
Posted by: Guest on June-27-2020
10

expressjs query params

// GET /search?q=tobi+ferret
console.dir(req.query.q)
// => 'tobi ferret'

// GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse
console.dir(req.query.order)
// => 'desc'

console.dir(req.query.shoe.color)
// => 'blue'

console.dir(req.query.shoe.type)
// => 'converse'

// GET /shoes?color[]=blue&color[]=black&color[]=red
console.dir(req.query.color)
// => ['blue', 'black', 'red']
Posted by: Guest on May-29-2020
0

express get query parameters

//get query¶ms in express

//etc. example.com/user/000000?sex=female

app.get('/user/:id', function(req, res) {
  const query = req.query;// query = {sex:"female"}
  const params = req.params; //params = {id:"000000"}

})
Posted by: Guest on May-29-2021

Code answers related to "express get query parameters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language