nodejs express api
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}`)
})
nodejs express api
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}`)
})
nodeJS rest api
// My dependencies
const express = require("express");
const bodyParser = require("body-parser");
// App configurations
const app = express();
// Let the app be able to see the html file that called the server
app.use(bodyParser.urlencoded({ extended: true }));
// A RESTFul GET API
app.get("/", (req, res) => {
res.send("Hello World");
});
// Another RESTFul GET API
app.get("/api/course", (req, res) => {
res.send([1,2,3]);
});
// My parameters input RESTFul API
app.get("/test/:year/:month", (req, res) => {
// http://localhost:55555/test/2020/5
res.send(req.params);
});
// My parameters input POST RESTFul API
app.post("/test2/:year/:month", (req, res) => {
// Same as the above one but with POST method
res.send(req.params);
});
// Starting up the server
const port = 55555;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us