import {createServer} from 'http'
const PORT = process.env.PORT
const users = [
{id:1, name:"Jim"},
{id:2, name:"Dwight"},
{id:3, name:"Michael"}
]
const server = createServer((res,req)=>{
if(req.url === "myapi/user" && req.method === "GET"){
res.setHeader('Content-Type','application/json')
res.write(JSON.stringify(users))
res.end()
}
})
server.listen(PORT,()=>{
console.log(`Server running on port here: ${PORT}`)
})
After running the code instead of getting a response of “name” array in my postman response it is just continuing the loading and never ends. Same with browser