인프런 커뮤니티 질문&답변

jhreplay.lee님의 프로필 이미지

작성한 질문수

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

[기본 nodeJS 서버 만들기] res.send is not a function

해결된 질문

23.11.04 10:48 작성

·

379

0

const http = require('http');

const host = 'localhost';
const port = 3000;

const server = http.createServer((req, res) => {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.send('<h1>Hello World</h1>');
});

server.listen(port, host, () => {
    console.log('Server running on http://localhost:3000...');
});
TypeError: res.send is not a function

이런 에러가 발생하는데 이유를 알 수 있을까요?

답변 1

0

코드팩토리님의 프로필 이미지
코드팩토리
지식공유자

2023. 11. 04. 10:59

안녕하세요!

강의 조금 더 진행 해보시면 res.end로 변경하는걸 볼 수 있습니다.

불편을드려 죄송합니다.

감사합니다!