问答详情
源自:3-4 核心:http模块

为何writeHead一用就报错呢

let http = require('http');

let fs = require('fs');

http.createServer((request, response) => {

    fs.readFile(`./${request.url}`, (error, data) => {

            if (error) {

                request.writeHead(404);

                request.end('404 not fonund');

            } else {

                response.writeHead(200);

                response.end(data);

            }

        })

        // response.end('the end');

}).listen(8888);

http://img.mukewang.com/5ea66d890001cf9311220211.jpg

提问者:金刚无敌葫芦娃 2020-04-27 13:29

个回答

  • 淡雅沐沐
    2020-04-29 10:46:08

    http://img3.mukewang.com/5ea8ea590001773306940529.jpg

    这个写错了