在请求里面自定义添加headers,Authorization和X-Hello,程序收到的是小写的authorization及x-hello,装饰器不加参数是全部对象,加参数是获取某一个头部信息,获取多个怎么拿?
This commit is contained in:
parent
245af79f31
commit
585c6f6b28
|
@ -3,7 +3,7 @@ import { Controller, Get, Req, Query, Headers } from '@nestjs/common';
|
||||||
@Controller('posts')
|
@Controller('posts')
|
||||||
export class PostsController {
|
export class PostsController {
|
||||||
@Get()
|
@Get()
|
||||||
index(@Headers() headers, @Query() query) {
|
index(@Headers('authorization') headers, @Query() query) {
|
||||||
console.log(headers)
|
console.log(headers)
|
||||||
console.log(query)
|
console.log(query)
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Reference in New Issue