[英]How to get properties of Loggedin user in Nestjs
我可以使用這個const loggedin = this.request.user
export class PostService {
constructor(
@Inject(REQUEST) private request: Request,
private userService: UserService
) { }
async GetPosts(){
const loggedin = this.request.user
loggedin.firstname;
}
}
但我無法訪問當前用戶的屬性
我試過loggedin.firstname
但我得到Property 'firstname' does not exist on type 'User'
我怎樣才能解決這個問題?
我解決問題,
export class PostService {
constructor(
@Inject(REQUEST) private request: any,
private userService: UserService
) { }
async GetPosts(){
const loggedin = this.request.user
}
}
我將請求類型更改為any
類型並像這樣解構它
const { _id, firstname } = this.request.user
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.