Dandy Now!
  • [Vue.js][문제해결] axios 오류 errno: 1064
    2022년 04월 25일 19시 27분 19초에 업로드 된 글입니다.
    작성자: DandyNow
    728x90
    반응형

    [그림 1]과 같이 카테고리 데이터를 수정(put)하는 기능을 적용하고 테스트하였는데 문제가 생겼다.

    [그림 1] 데이터 수정 기능 테스트

     

    콘솔에 [그림 2]와 같은 오류가 발생하였고,

    [그림 12] 저장 직후 발생한 오류

     

    다음과 같이 node 서버가 강제 중단되었다.

    PS C:\Users\J\Documents\GitHub\bootcamp\project\server> node .\app.js
    서버가 포트 3000번으로 시작되었습니다.
    Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL where product_category_id='13'' at line 1
        at Query.Sequence._packetToError (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
        at Query.ErrorPacket (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\sequences\Query.js:79:18)
        at Protocol._parsePacket (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\Protocol.js:291:23)
        at Parser._parsePacket (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\Parser.js:433:10)
        at Parser.write (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\Parser.js:43:10)
        at Protocol.write (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\protocol\Protocol.js:38:16)
        at Socket.<anonymous> (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\Connection.js:88:28)
        at Socket.<anonymous> (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\Connection.js:526:10)
        at Socket.emit (node:events:390:28)
        at addChunk (node:internal/streams/readable:315:12)
        --------------------
        at Pool.query (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\mysql\lib\Pool.js:199:23)
        at C:\Users\J\Documents\GitHub\bootcamp\project\server\mysql\index.js:25:10
        at new Promise (<anonymous>)
        at Object.query (C:\Users\J\Documents\GitHub\bootcamp\project\server\mysql\index.js:24:10)
        at C:\Users\J\Documents\GitHub\bootcamp\project\server\routes\product.js:23:30
        at Layer.handle [as handle_request] (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\express\lib\router\layer.js:95:5)
        at next (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\express\lib\router\route.js:137:13)
        at Route.dispatch (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\express\lib\router\route.js:112:3)
        at Layer.handle [as handle_request] (C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\express\lib\router\layer.js:95:5)
        at C:\Users\J\Documents\GitHub\bootcamp\project\server\node_modules\express\lib\router\index.js:281:22 {
      code: 'ER_PARSE_ERROR',
      errno: 1064,
      sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL where product_category_id='13'' at line 1",
      sqlState: '42000',
      index: 0,
      sql: "update product_category set NULL where product_category_id='13'"
    }
    node:internal/process/promises:246
              triggerUncaughtException(err, true /* fromPromise */);
              ^
    
    [UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<Object>".] {
      code: 'ERR_UNHANDLED_REJECTION'
    }

     

    axios defaults 설정 시 오타가 문제의 원인이었다.

    // client/src/mixins/index.js
    ...
    axios.defaults.baseURL = 'http://localhost:3000'
    axios.defaults.headers['Content-Type'] = 'aplication/json;charset=utf-8' // aplication -> application
    axios.defaults.headers['Access-Control-Allow-Origin'] = '*'
    ...

     

    728x90
    반응형
    댓글