I noticed that if i want to return something from an API using NESTJs, i can use return statement or to use response like that:
@Controller('dashboard')
export class DashboardController {
@Get()
findAll(
@Res() response: Response,
): any {
response.send({
result: JSON.stringify(['data'])
});
}
}
OR
@Controller('dashboard')
export class DashboardController {
@Get()
findAll(
): any {
return JSON.stringify(['data']);
}
}
In one case i used response.send() and in the second return statement.
Question: What is the difference between these 2 methods?