W3LABKR

고정 헤더 영역

글 제목

메뉴 레이어

W3LABKR

메뉴 리스트

  • 홈
  • 태그
  • 방명록
  • 분류 전체보기 (6)
    • Code Snippets (5)
      • HTML (0)
      • CSS (0)
      • Javascript (2)
      • jQuery (0)
      • ReactJS (0)
      • NodeJS (1)
      • PHP (2)
      • Python (0)
      • ShellScript (0)
      • WordPress (0)
      • Git (0)
    • Tools (1)
      • VisualStudioCode (1)
      • SublimeText3 (0)
    • Cloud Computing Services (0)
      • AmazonWebService (0)
      • GoogleCloudPlatform (0)
      • NaverCloudPlatform (0)

검색 레이어

W3LABKR

검색 영역

컨텐츠 검색

RES

  • How to send formatted json in expressjs?

    2021.12.08 by w3labkr

How to send formatted json in expressjs?

app.js app.set('json spaces', 4); You're going to have to set the Content-Type to application/json like this app.get('/', function (req, res) { users.find({}).toArray(function(err, results){ res.header("Content-Type",'application/json'); res.send(JSON.stringify(results, null, 4)); }); }); node and express send json formatted node and express send json formatted I'm trying to send formatted json ..

Code Snippets/NodeJS 2021. 12. 8. 22:20

추가 정보

인기글

최신글

페이징

이전
1
다음
TISTORY
W3LABKR © Magazine Lab
페이스북 트위터 인스타그램 유투브 메일

티스토리툴바