-
-
Save MrCube42/3b4d1e6668d86040468ecfee71aa7712 to your computer and use it in GitHub Desktop.
Implementierung einer POST Route, die über ihren Body das zuvor als TypeScript Klasse definierte Datentransfer-Objekt entgegennimmt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Body, Controller, Post } from '@nestjs/common'; | |
class ContactDto { | |
readonly myId: string; | |
readonly contactId: string; | |
} | |
@Controller('contact') | |
export class ContactController { | |
@Post() | |
sayHello(@Body() contactDto: ContactDto): string { | |
const { myId, contactId } = contactDto; | |
// … Freund mit ID myId sagt ‘Hallo’ zu Freund mit ID contactId | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment