• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

config.authCookieName 에서 타입 오류가 발생합니다.

24.07.02 15:40 작성 조회수 42

0

  • [vue-tsc] Argument of type 'unknown' is not assignable to parameter of type 'string'.
    /workspace/dev/nuxt-tutorial/server/routes/auth/login.post.ts:38:20
        36 |
        37 |   const config = useRuntimeConfig();
      > 38 |   setCookie(event, config.authCookieName, JSON.stringify(userWithoutPassword));
           |                    ^^^^^^^^^^^^^^^^^^^^^
        39 |
        40 |   return {
        41 |     user: userWithoutPassword,
  • [vue-tsc] Argument of type 'unknown' is not assignable to parameter of type 'string'.

    /workspace/dev/nuxt-tutorial/server/utils/auth.ts:5:43
        3 | export function getUserFromEvent(event: H3Event) {
        4 |   const config = useRuntimeConfig();
      > 5 |   const userJsonString = getCookie(event, config.authCookieName);
          |                                           ^^^^^^^^^^^^^^^^^^^^^
        6 |
        7 |   console.log('userJsonString: ', userJsonString);

config.authCookieName 

에서 타입 오류가 발생하는데 어떻게 해결 할 수 있을까요..?

답변 1

답변을 작성해보세요.

0

안녕하세요 😀

RuntimeConfig Type 관련해서 아래 링크를 참고하시면 될 것 같습니다.

https://nuxt.com/docs/guide/going-further/runtime-config#typing-runtime-config

채널톡 아이콘