-
-
Save N-Hidaya/1a8c0ff2a7d1f45787415ec548581680 to your computer and use it in GitHub Desktop.
final code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const cors = require('cors') | |
const app = express(); | |
const about = require('./routes/about') | |
//middleware for server | |
app.use(express.json()); | |
//to make API publicly accessible | |
app.use(cors()); | |
//Register router from about | |
app.use('/about', about) | |
app.get('/', (req, res) => { | |
res.json('Welcome to the API') | |
}) | |
//Listen for a connection | |
const port = process.env.PORT || 5500; | |
app.listen(port, () => console.log(`Listening to Port: ${port}`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment