What do you want to save?
Add Code snippet
New code examples
-
Other 2022-03-27 19:45:11
ReferenceError: require is not defined site:stackoverflow.com
const cors = require('cors'); const express = require('express'); const bodyParser = require('body-parser'); var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, { 'Content-Type': 'text/plain' }); ... Add solution -
Javascript 2022-03-27 16:10:42
i need to add content-type accept form data using node.js in middelware
var express = require('express'); var app = express(); var multer = require('multer'); var upload = multer(); // for parsing application/json app.use(express.json()); // for parsing application/x-www-form-urlencoded app.use(express.urlencoded({ extende... Add solution -
Javascript 2022-03-27 08:05:04
express req get json
const express = require('express'); const app = express(); app.use(express.json()); app.post('*', (req, res) => { req.body; // The json object sent to the server }); const port = 3000; app.listen(port, () => console.log(`Listening on port ${port... Add solution -
Javascript 2022-03-26 22:10:08
express() vs express.router()
var express = require('express'); var fs = require('fs'); var app= express(); app.get('/index/profile/:id',function(req,res){ // res.send('profile with id' + req.params.id) }); app.listen(3000,'127.0.0.1'); console.log('lsitng'); Add solution -
Javascript 2022-03-19 19:50:06
express getting options instead of post
// 'OPTIONS' is a standard request send by browsers BEFORE your request // Your server needs to handle these requests appropriately // Please see source and upvote the answer I got this from to share credit var express = require('express') , cors = req... Add solution -
Javascript 2022-03-16 21:05:03
my js
const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => res.send('Hello World!')) var points = [40, 100, 1, 5, 25, 10]; points.sort((a,b) => a-b) var newArray = array.filter(function(item) { return ... Add solution -
Javascript 2022-03-06 17:00:21
How to access the request body when POSTing using Node.js and Express
const express = require('express'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.post('/post-test', (req, res) => { console.log('Got body:', req.body); res.sendStatu... Add solution -
Javascript 2022-03-05 14:35:24
app.post('/', function (req, res) { res.send('POST request to homepage') })
var express = require("express"); var bodyParser = require("body-parser"); var app = express(); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.get('/... Add solution -
Javascript 2022-03-04 03:25:05
express cors policy
var express = require('express') var cors = require('cors') var app = express() app.use(cors()) app.get('/products/:id', function (req, res, next) { res.json({msg: 'This is CORS-enabled for all origins!'}) }) app.listen(80, function () { console.lo... Add solution