PayloadTooLargeError: request entity too large
,当我尝试从Angular6中将某些内容发布到SQL Server时出现此错误
这是我要发布的内容:
[
{
'name': 'john',
'projects': ["P1", "P2", ... "P4500"] // so this is an array with 4500 elements
}
]
我尝试使用:
var bodyParser = require('body-parser');
app.use(bodyParser.json({
limit: '50mb'
}));
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
}));
但我仍然收到错误消息。
这是我的路由器,如果有帮助的话:
router.post('/addMoreProjects', (req, res, next) => {
var projArr = req.body.projects.split(',')
for (var i in projArr ) {
knex.from('users')
.insert({
name: req.body.name,
projects: projArr[i]
})
.then((project) => {
res.json(project);
})
.catch((err) => {
res.send(err);
})
}
});
.ts
addProject() {
let project = {
name: this.name,
projects: this.projectsArray.toString()
}
this.projService.addMoreProjects(JSON.stringify(project)).then(() => {})
}
服务
addMoreProjects(projectBody: any) {
return this.http.post(environment.rootURL + "/projects/addMoreProjects", projectBody, { headers: this.setHeaders() }).toPromise()
.then((project) => {
return project;
}).catch((error) => {
return error;
})
}
如何解决此问题?谢谢您的时间!