본문 바로가기

반응형

웹프로그래밍

(125)
[node.js] How to get POST a query in Express.js/Node.js?
[node.js] How to access the GET parameters in Express.js or Node.js? /?parameter="test" 기존 request.param("parameter") 에서... 아래와 같이 업데이트됨; var app = express(); app.post 일때, request.body.parameter app.get 일때, request.params.parameter 어떤 방식으로 값이 들어오는지 보려면 console.log(request.params); console.log(request.body); console.log(request.query); 를 찍어보자.. 또한 app.use(bodyParser.urlencoded({ extended: true })); bodyParser 가 urlencoded 로 되어 있어야된다. JSON으로 되있을 경우 JSON 형식만 읽어오기떄문에..
[node.js] Most middleware (like logger) is no longer bundled with Express and must be installed separately... 『모던 웹을 위한 Node.js 프로그래밍』보면서 차근히 따라하고 있는데.. express에서 미들웨어 사용하다가 난관에 부딪혔다. logger 쓰려고 했더니, 에러가 빡!! 미들웨어가 더이상 번들로 설치되어 있는 게 아니니 따로 설치하란다. 이게 뭔...? 또다시 구글링... 구글링구글구긆릉르르르ㅏ르르르르 http://stackoverflow.com/questions/23526356/heroku-node-js-server-crash-with-error-most-middleware-like-logger-is-no-lo ↑ 이 사람 글을 보니, 2가지 방법이 있댄다. logger 대신에 morgan을 설치해서 사용하든가, express가 설치된 폴더 안에서 package.json 파일을 찾아서 expres..
[node.js] express cookie-parser Installation $ npm install cookie-parser API var express = require('express') var cookieParser = require('cookie-parser') var app = express() app.use(cookieParser()) cookieParser(secret, options) secret a string used for signing cookies. This is optional and if not specified, will not parse signed cookies. options an object that is passed to cookie.parse as the second option. See cookie for more..
[node.js] Check synchronously if file/directory exists in Node.js http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js
[node.js] file upload Server.js /*Define dependencies.*/ var express=require("express"); var multer = require('multer'); var app=express(); var done=false; /*Configure the multer.*/ app.use(multer({ dest: './uploads/', rename: function (fieldname, filename) { return filename+Date.now(); }, onFileUploadStart: function (file) { console.log(file.originalname + ' is starting ...') }, onFileUploadComplete: function (file)..
[node.js] bodyParser deprecated http://stackoverflow.com/questions/24330014/bodyparser-is-deprecated-express-4 express/connect top-level generic This example demonstrates adding a generic JSON and URL-encoded parser as a top-level middleware, which will parse the bodies of all incoming requests. This is the simplest setup. var express = require('express') var bodyParser = require('body-parser') var app = express() // parse app..
[node.js] .router' is deprecated! 위 오류가 날때... app.router 를 use 하는 라인을 지워주면 된다. 예전에는 넣어줘야되는데 최신버젼에선 없어졌다고 한다.

반응형