question: @Body() empty with @Controller?
See original GitHub issueHi guys,
Whenever I use @Controller I seems to not receive JSON body content. It works when I use @Jsoncontroller, am I missing anything?
I use createExpressApp, I tried version 0.8 and 0.9 and express 4 and 3. @Controller always return {} while Jsoncontroller works.
@Controller('/templates')
export class TemplateController {
@Post('/:name')
public getTemplate(@Param('name') templateName: string, @Body() body: any): string {
return this.templateService.render(templateName, body)
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Body is empty during POST method to server controller
I'm requesting a send response from my client containing an object, but on my back-end, when i console.log(req.body), the server shows it being ......
Read more >JAVA - Getting empty MockHttpServletResponse: | Chegg.com
Question : JAVA - Getting empty MockHttpServletResponse: body..However it's 200. package com.controller; import javax.validation.constraints.NotBlank; import ...
Read more >Component Body is empty after init event but not from Chrome ...
And this is what happens from c:carouselComponent controller in init handler : onInit: function(component, event, helper) { var body = component ...
Read more >Response with empty body - is this a problem? - jQuery Forum
Hi, I am using Chrome to send a request from the browser to the Micrium HTTP server, which is successfully received by the...
Read more >ViewModel data is empty on form submit when using ...
public IPagedList PagingMetaData { get; set; }; }; }. Controller code:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@posabsolute @ivanproskuryakov You have to add
bodyParser
import express from “express”; import bodyParser from ‘body-parser’;
server.use(bodyParser.json()); server.use(bodyParser.urlencoded({extended: true}));
useExpressServer(server, {});
server.listen(PORT, function () { console.log(‘Example app listening on port 3000’) });
Hi @antowkabond, thanks, this is working indeed.