body-parser

How can I use body-parser with LoopBack?

醉酒当歌 提交于 2019-12-18 11:07:03
问题 I see that LoopBack has the Express 3.x middleware built-in. Indeed, body-parser is in loopback/node_modules . But I cannot figure out how to use it as middleware. I have never worked with Express 3.x, so maybe it's just that. require does not work, obviously, unless I install body-parser as a dependency in my project. What should I do in server.js to use body-parser so that web forms are parsed into req.params ? That's what it does, right? 回答1: After hours of frustration, I just added it to

$http.post: Large files do not work

妖精的绣舞 提交于 2019-12-18 09:01:31
问题 I am trying to upload files through my web app using the following code. View: <form name="uploadForm" class="form-horizontal col-sm-12"> <div class="col-sm-4"> <input type="file" ng-model="rsdCtrl.viewData.file" name="file"/> </div> <div class="col-sm-4"> <button class="btn btn-success" type="submit" ng-click="uploadFile()">Upload</button> </div> </form> Controller: function uploadFile(){ if (uploadForm.file.$valid && file) { return uploadService.upload(vd.file, "Convictions Calculator",

get req.body.task is undefined after click on checkbox

自闭症网瘾萝莉.ら 提交于 2019-12-14 03:27:30
问题 When I have click on checkbox then req.body.task return undefined . <input type="checkbox" name="task" autocomplete="off" checked="" onchange="onToDochange({{id}})"> Perform on change function which return id of checked or unchecked checkbox. function onToDochange(id) { // console.log(id); fetch('/checkbox', { method: 'POST', body: JSON.stringify({global: id}) }) .then(res=>res.json()) .then(res => console.log(res)); }; Routing app.post('/checkbox', (req, res) => { console.log(req.body.task);

Parse cloud code error for body-parser on npm start command

≡放荡痞女 提交于 2019-12-13 20:24:54
问题 I have created the project for parse cloud code and now I am trying to start it using node.js When I run start npm command it gives following error. :\Project>npm start > parse-server-example@1.4.0 start C:\Project > node index.js 1 C:\Project\node_modules\express\lib\express.js:89 throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/sen chalabs/connect#middleware.'); ^ Error: Most middleware

Why don't newer versions of node remove __proto__ from request body?

谁都会走 提交于 2019-12-13 18:44:29
问题 When I send a PUT request to my express server, req.body sometimes has a __proto__ property, and other times not. Using node 0.10.26 and express 3.2.3 : When I put {"a":"b", "__proto__": {}} , Then req.body is {"a":"b"} Using node 4.1.0 and express 3.2.3 : When I put {"a":"b", "__proto__": {}} , Then req.body is {"a":"b", "__proto__": {}} So newer versions of node do not strip the __proto__ property. I actually liked this behaviour; now I have to write my own middleware which strips away the

How to fetch fields from request in Node.js using express framework?

旧街凉风 提交于 2019-12-13 11:35:56
问题 I am writing a Node.js script and having problems with integration of a "login" form. I can do it using a static HTML page, however using a dynamic ".ejs" page is causing problems...my form fields are reported as "undefined". var helmet = require('helmet'); var bodyParser = require('body-parser') //var cookieParser = require('cookie-parser'); //var csurf = require('csurf'); //Use Express module var express = require('express'); var app = express(); var io = require("socket.io"); //web socket

BodyParser parse data instead of connect-multiparty in node.js

自古美人都是妖i 提交于 2019-12-13 08:58:27
问题 I am trying to upload file using connect-multiparty with reference of connect-multiparty below is my express.js config for that. app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); //file upload configuration app.use(multipart({ uploadDir: config.tmp })); but when I upload file than it gives me request size if too long. I search for this and found that I need to set limit so I have also put limit parameter like below: app.use(bodyParser.json({limit:'50mb'})); but

Sails.js :remove bodyparser middleware for a specific route

巧了我就是萌 提交于 2019-12-12 10:15:07
问题 Is there any way to remove middleware for a particular route currently all the middlewares are listed in http.js file [ 'startRequestTimer', 'cookieParser', 'session', 'bodyParser', 'passportInit', 'passportSession', 'myRequestLogger', 'handleBodyParserError', 'compress', 'methodOverride', 'poweredBy', 'router', 'www', 'favicon', '404', '500' ] I want to remove the bodyParser middleware for a particular route Is it possible with sails.js?? 回答1: There's no mechanism for doing this

Unobtrusive middle-ware for Expres.js to inspect request body

佐手、 提交于 2019-12-11 11:45:50
问题 Does there exist a thirdparty middleware or a way to create such middleware for Express.js that allows for intercepting all requests and inspecting the request's body content without affecting subsequent middleware such as bodyParser or route endpoints which may rely on the raw body such as express-http-proxy? From what I can tell bodyParser itself seems to work in a somewhat obtrusive way that does not allow a route to override the default parsing behavior. The express documentation

Express4.10 bodyParser req.body undefined

南笙酒味 提交于 2019-12-11 11:15:41
问题 I'm trying to build the login of a node application trying to access the route / login get: req.body undefined Error: TypeError: Cannot read property 'usuario' of undefined at login (/home/makros/workspace/ntalk/controllers/home.js:8:24) at Layer.handle [as handle_request] (/home/makros/workspace/ntalk/node_modules/express/lib/router/layer.js:82:5) at next (/home/makros/workspace/ntalk/node_modules/express/lib/router/route.js:100:13) at Route.dispatch (/home/makros/workspace/ntalk/node