Search this site
Embedded Files
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
  • More
    • Home
    • My Note
      • Linux
      • Node js
      • Docker
      • PostgreSQL
      • Hadoop
      • Python
      • JavaScript
      • Express
      • ShellScript
      • Github
      • Next js
      • Node-Red
    • Full Projects
      • bot_telegram
    • About me

list contents

Express

Route

Express request

req.query.id  

  • Pengambilan data : mengambil data dari tambahan query di belakang ULR. seperti menambahkan filter berdasarkan pamameter yang sudah di siapkan  atou  form ( contoh : http://localhost:3000/search  =>  http://localhost:3000/search?id=1234)

  • Kapan di gunakan: saat mebutuhkan satu alamat URL dan membutuhan berbagai inputan parameter seperti form  


app.get('/search', (req, res) => {

    const searchTerm = req.query.id;

    // Do something with the search term

    });

req.param.id 

  • Pengambilan data : mengambil data dari bagian URL yang berubah dengan variabel ditandai dengan :id  

( contoh : http://localhost:3000/user/:id  =>  http://localhost:3000/user/1234)

  • Kapan di gunakan: saat membutuhkan banyak alamat URL dengan source yang sama 


app.get('/search', (req, res) => {

    const searchTerm = req.query.id;

    // Do something with the search term

    });

req.body

berfungsi untuk menangkap nilai yang dikirimkan melalui form-html (interface)

  • Pengambilan data : mengambil data dari FORM

<form action=”/search” method=”post”>

<input type=”text” nama=”id” placeholder=”id”>

<button type=”submit”>Search</button>

</form>


  • pemanggilan library di express


//memanggil library

var bodyParser = require(‘body-parser’);

//menggunakan library pada express

app.use(bodyParser.urlencoded({ extended: false }))

app.use(bodyParser.json())



app.get('/search', (req, res) => {

    const searchTerm = req.body.id;

    // Do something with the search term

    });

Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse