whats wrong of my code ? ------------ const http = require("http"); const url = require('url'); const app = express() var hostName = '127.0.0.1'; var port = 3000; var server = http.createServer(function(req,res){ res.setHeader('Content-Type','text/plain'); const parsed = url.parse(req.url); const pathname = parsed['pathname'] const queryObject = url.parse(req.url,true).query; let queryValue = queryObject['name'] if(queryValue==null){ queryValue="" } if (pathname=="/"){ res.end("SUCCESS!") } else if (pathname=="/echo"){ res.end("SUCCESS! echo") } app.get('/foxtrot/:value', (req, res) => { res.send("SUCCESS! Received " + req.params.value + " via foxtrot") }) app.get('/*', (req, res) => { res.send("FAILED! Fix your URL.") }) app.listen(port,'0.0.1',()=>{ console.log('listening') }) server.listen(port,hostName,()=>{ console.log(`Server running at http://${hostName}:${port}/`); }); ------ when i am running it ,itshows "SyntaxError: Unexpected end of input ?[90m at wrapSafe (internal/modules/cjs/loader.js:1001:16)?[39m ?[90m at Module._compile (internal/modules/cjs/loader.js:1049:27)?[39m ?[90m at Object.Module._extensi
whats wrong of my code ?
------------
const http = require("http");
const url = require('url');
const app = express()
var hostName = '127.0.0.1';
var port = 3000;
var server = http.createServer(function(req,res){
res.setHeader('Content-Type','text/plain');
const parsed = url.parse(req.url);
const pathname = parsed['pathname']
const queryObject = url.parse(req.url,true).query;
let queryValue = queryObject['name']
if(queryValue==null){
queryValue=""
}
if (pathname=="/"){
res.end("SUCCESS!")
}
else if (pathname=="/echo"){
res.end("SUCCESS! echo")
}
app.get('/foxtrot/:value', (req, res) => {
res.send("SUCCESS! Received " + req.params.value + " via foxtrot")
})
app.get('/*', (req, res) => {
res.send("FAILED! Fix your URL.")
})
app.listen(port,'0.0.1',()=>{
console.log('listening')
})
server.listen(port,hostName,()=>{
console.log(`Server running at http://${hostName}:${port}/`);
});
------
when i am running it ,itshows "SyntaxError: Unexpected end of input
?[90m at wrapSafe (internal/modules/cjs/loader.js:1001:16)?[39m
?[90m at Module._compile (internal/modules/cjs/loader.js:1049:27)?[39m
?[90m at Object.Module._extensi
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images