how to set up an express api nodejs
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
3.78
9
const express = require('express')
const app = express()
app.get('/', (req, res, next) => {
res.json({
message: 'This is my JSON api'
});
});
app.listen(your-port-here, () => {
console.log(`listening on http://localhost:${the-port-goes-here}`)
});
/*
WombleWoo7547 @ https://github.com/WombleWoo7547 https://replit.com/@WombleWoo7547
*/
Thank you!
9
0
Are there any code examples left?
New code examples in category Javascript