Student Activity
Student Activity (30-min)
javascript코드 복사const http = require('http'); const tasks = [ { id: 1, title: 'Task 1' }, { id: 2, title: 'Task 2' } ]; const server = http.createServer((req, res) => { if (req.url === '/tasks') { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(tasks); // Bug: Not serialized as JSON } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not Found'); // Bug: Missing newline } }); server.listen(3000, () => { console.log('Server is running at http://localhost:3000'); });bash코드 복사node buggyApp.jsjavascript코드 복사res.end(JSON.stringify(tasks));
javascript코드 복사debugger;bash코드 복사node inspect buggyApp.js
bash코드 복사npm install -g clinicbash코드 복사clinic flame -- node buggyApp.js
Last updated