I am trying to implement a POST endpoint to my API, which returns an HTML string when called at.
My code looks like this at the moment:
import { Controller, Post } from '@nestjs/common';
@Controller()
export class MyController {
@Post('/endpoint')
public create(): string {
return `
<!DOCTYPE html>
…
</html>`;
}
}
How can I tell the POST endpoint to send the correct content-type together with it's response? I've searched all documentations but was not able to find anything helpful for me.
Thank you in advance for your help
I was able to find the answer myself. I just added the @Header
decorator just behind the @Post
decorator:
import { Header } from '@nestjs/common'
@Post('/endpoint')
@Header('content-type', 'text/html')
public create(): string {
//
}