UnhandledPromiseRejectionWarning : TypeError : 상수 변수 할당

호세 노브 르

사용자가 요청 본문에서 필터를 보낼 수 있도록 허용하기 위해 findAll () 메서드 외부에서 where 절을 수행하고 있습니다. 내 요청 본문의 값 중 하나는 전송 가능 여부에 관계없이 categoryId입니다.

이것은 내 코드입니다.

     const where = {}
        if (categoryId) {
            where = { '$subcategories.category_id$': categoryId
         }
        } 

    try {
            const establishments = await establishment.findAll({
                attributes: [
                    "id",
                    "description",
                    "latitude",
                    "longitude",
                    [sequelize.literal(' (6371 * acos ( '
                        + 'cos( radians(' + latitude + ') ) '
                        + '* cos( radians( latitude ) ) '
                        + '* cos( radians( longitude ) - radians(' + longitude + ') )'
                        + '+ sin( radians(' + latitude + ') )'
                        + '* sin( radians( latitude ))))'), 'distance']
                ],
                include: [{
                    attributes: [],
                    model: subcategory, as: 'subcategories',
                    required: false,
                },
                {
                    attributes: ["id", "name"],
                    model: certificate, as: 'certificates',
                    required: false,
                },
                ],

                where: {
                    where
                },

                establishments: ['id'],
            });
 } catch (error) {
        console.log(error)
        res.status(400).json({ Error: "Error while fetching the establishment" });
    }

주어진 오류 :

UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
 UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch()
아카시 다탄

const일단 선언되면 변수에 값을 할당 할 수 없습니다 .

어느 쪽이든 사용 let

let where = {}

또는

const where = {}
if (categoryId) {
  where['subcategories.category_id'] = categoryId
}

변화 where: { where }where: where

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

TypeError : 상수 변수 할당. React.js 후크

분류에서Dev

변수 할당?

분류에서Dev

변수 할당

분류에서Dev

이상한 변수 할당

분류에서Dev

상수 변수 할당 오류

분류에서Dev

변수에 할당

분류에서Dev

OdiOSCommand 할당 변수

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : place.toObject가 함수가 아닙니다.

분류에서Dev

오류 : UnhandledPromiseRejectionWarning : TypeError : ytdl.validateURL이 함수가 아닙니다.

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : io.emit은 함수가 아닙니다.

분류에서Dev

matplotlib의 변수에 색상 할당?

분류에서Dev

TypeError : 개체 상태의 변수는 반복 할 수 없습니다.

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 속성 'password'를 읽을 수 없습니다.

분류에서Dev

[해결됨] (node : 65297) UnhandledPromiseRejectionWarning : TypeError : mem.addRole은 함수가 아닙니다.

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 'send'속성을 읽을 수 없습니다.

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 'replace'속성을 읽을 수 없습니다.

분류에서Dev

UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 속성 'id'를 읽을 수 없습니다.

분류에서Dev

(caadr exp) 할당 변수

분류에서Dev

C 다중 변수 할당

분류에서Dev

변수 Guzzle에 getBody () 할당

분류에서Dev

변수 할당의 속기

분류에서Dev

$ .ajax를 변수에 할당

분류에서Dev

KornShell의 변수 할당

분류에서Dev

C 변수 할당 문제

분류에서Dev

변수 할당 순서

분류에서Dev

if 내의 zsh 변수 할당

분류에서Dev

if 내의 zsh 변수 할당

분류에서Dev

Matlab 다중 변수 할당

분류에서Dev

select 문에 변수 할당

Related 관련 기사

  1. 1

    TypeError : 상수 변수 할당. React.js 후크

  2. 2

    변수 할당?

  3. 3

    변수 할당

  4. 4

    이상한 변수 할당

  5. 5

    상수 변수 할당 오류

  6. 6

    변수에 할당

  7. 7

    OdiOSCommand 할당 변수

  8. 8

    UnhandledPromiseRejectionWarning : TypeError : place.toObject가 함수가 아닙니다.

  9. 9

    오류 : UnhandledPromiseRejectionWarning : TypeError : ytdl.validateURL이 함수가 아닙니다.

  10. 10

    UnhandledPromiseRejectionWarning : TypeError : io.emit은 함수가 아닙니다.

  11. 11

    matplotlib의 변수에 색상 할당?

  12. 12

    TypeError : 개체 상태의 변수는 반복 할 수 없습니다.

  13. 13

    UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 속성 'password'를 읽을 수 없습니다.

  14. 14

    [해결됨] (node : 65297) UnhandledPromiseRejectionWarning : TypeError : mem.addRole은 함수가 아닙니다.

  15. 15

    UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 'send'속성을 읽을 수 없습니다.

  16. 16

    UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 'replace'속성을 읽을 수 없습니다.

  17. 17

    UnhandledPromiseRejectionWarning : TypeError : 정의되지 않은 속성 'id'를 읽을 수 없습니다.

  18. 18

    (caadr exp) 할당 변수

  19. 19

    C 다중 변수 할당

  20. 20

    변수 Guzzle에 getBody () 할당

  21. 21

    변수 할당의 속기

  22. 22

    $ .ajax를 변수에 할당

  23. 23

    KornShell의 변수 할당

  24. 24

    C 변수 할당 문제

  25. 25

    변수 할당 순서

  26. 26

    if 내의 zsh 변수 할당

  27. 27

    if 내의 zsh 변수 할당

  28. 28

    Matlab 다중 변수 할당

  29. 29

    select 문에 변수 할당

뜨겁다태그

보관