[Node.js] plain text 받기

Yeon Jeffrey Seo·2022년 2월 21일
0

express app 세팅시 bodyParser로 text를 추가해주면 된다.

// app.js

const app = require("express").express();
const bodyParser = require("body-parser");

...
app.use(bodyParser.text());
...

컨트롤러에서는 request의 body만 콘솔에 출력해보았다.

postman 테스트

콘솔 출력 결과

json format을 지키지 않아도 문자 그대로 plain text 전체가 넘어온다.

사실 쓸 일은 별로 없을 것 같다.

profile
The best time to plant a tree was twenty years ago. The second best time is now.

0개의 댓글