Guest User

Untitled

a guest
Aug 10th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. const express = require("express"); // เสมือน import package มาใช้งาน
  2. const app = express(); // สร้าง Express Application ลองกด ctrl + คลิกเข้าไปดูในไส้ใน
  3. const cookieParser = require("cookie-parser");
  4. const bodyParser = require("body-parser");
  5.  
  6. // MiddleWare คือตัวกลางที่ใช้ในการจัดการข้อมูลก่อนที่จะผ่านเข้ามายัง request
  7. // เราลง middleware cookieParser() เอาไว้สำหรับอ่าน header cookie ไม่อย่างนั้นมันจะหาไม่เจอและพังตลอดนั่นเอง
  8. app.use(cookieParser());
  9. app.use(bodyParser.json()); // ให้รองรับ json encoded bodies
  10. app.use(bodyParser.urlencoded({ extended: true })); // ให้รองรับ urlencoded bodies
Add Comment
Please, Sign In to add comment