강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của taejunb708321
taejunb708321

câu hỏi đã được viết

Tìm hiểu NestJS bằng cách làm theo

Thực hiện chức năng đăng nhập

auth.service.ts에서 오류가 납니다

Viết

·

938

0

auth.service.ts username에서 에러가 납니다.

에러내용은 다음과 같습니다.

 

{ username: string; }' 형식의 인수는 'FindOneOptions<User>' 형식의 매개 변수에 할당될 수 없습니다.
개체 리터럴은 알려진 속성만 지정할 수 있으며 'FindOneOptions<User>' 형식에 'username'이(가) 없습니다.ts(2345)

 

postgresqljwtnestjstypeorm

Câu trả lời 2

1

 

저는 이렇게 하니 되네요

 const user = await this.userRepository.findOne({ where: { username } });
export interface FindOneOptions<Entity = any> {
    /**
     * Adds a comment with the supplied string in the generated query.  This is
     * helpful for debugging purposes, such as finding a specific query in the
     * database server's logs, or for categorization using an APM product.
     */
    comment?: string;
    /**
     * Specifies what columns should be retrieved.
     */
    select?: FindOptionsSelect<Entity> | FindOptionsSelectByString<Entity>;
    /**
     * Simple condition that should be applied to match entities.
     */
    where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>;

0

안녕하세요, 인프런 AI 인턴이에요.

auth.service.ts에서 발생한 에러로 보입니다. 해당 에러는 ‘FindOneOptions’ 형식의 매개 변수에 ‘username: string’이라는 타입이 할당될 수 없다는 내용입니다. 이런 경우, 해당 변수를 지정된 타입으로 변환해주어야 할 것입니다.

문제가 무엇인지 정확하게 파악하기 위해서는 코드 상세 내용을 살펴봐야할 것 같습니다. but, 위에서 언급한 내용으로 문제가 해결되지 않을 겨우, 코드를 제공해주시면 상세한 답변을 드릴 수 있을 거예요.

더 정확한 답변을 드리지 못해 죄송합니다.

Hình ảnh hồ sơ của taejunb708321
taejunb708321

câu hỏi đã được viết

Đặt câu hỏi