이미지 업로드 시 발생하는 에러 ?
Error: Unexpected end of form
at Multipart._final (C:\Users\DY\Desktop\pintre\node_modules\busboy\lib\types\multipart.js:588:17)
at callFinal (node:internal/streams/writable:698:12)
at prefinish (node:internal/streams/writable:710:7)
at finishMaybe (node:internal/streams/writable:720:5)
at Writable.end (node:internal/streams/writable:634:5)
at IncomingMessage.onend (node:internal/streams/readable:705:10)
at Object.onceWrapper (node:events:627:28)
at IncomingMessage.emit (node:events:513:28)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
req.prams에 전달되는 pinId를 못 읽는다.
API요청 POST method localhost:3000/api/pin/1/comment
class CommentController {
constructor() {
this.commentService = new CommentService();
}
addComment = async (req, res, next) => {
logger.info(`CommentService.addComment Request`);
const { pinId } = req.params;
const userId = Math.floor(Math.random() * 11);
const { content } = req.body;
console.log( userId, req.params, content );
try {
const comment = await this.commentService.addComment({
userId,
pinId,
content,
});
res.status(201).json({ comment });
} catch (error) {
next(error);
}
};
PS C:\Users\DY\Desktop\pintre> node app.js
2023-03-05 10:24:59 info: undefined - API Server Listening At Port 3000
2023-03-05 10:25:02 info: CommentService.addComment Request
{ userId: 2, pinId: undefined, content: '내용' }
2023-03-05 10:25:02 info: CommentService.addComment
2023-03-05 10:25:02 info: PinRepository.findByPinId
Error: WHERE parameter "pinId" has invalid "undefined" value
at MySQLQueryGenerator.whereItemQuery (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1705:13)
at C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1696:25
at Array.forEach (<anonymous>)
at MySQLQueryGenerator.whereItemsQuery (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1694:35)
at MySQLQueryGenerator.getWhereConditions (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-generator.js:2037:19)
at MySQLQueryGenerator.selectQuery (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-generator.js:954:28)
at MySQLQueryInterface.select (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\dialects\abstract\query-interface.js:407:59)
at Pins.findAll (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\model.js:1134:47)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Pins.findOne (C:\Users\DY\Desktop\pintre\node_modules\sequelize\lib\model.js:1228:12)
ㅡㅡ index에 :pinId넣으면 실행이 안됨, pin.route에 넣어야함 이걸어캐알아아아망마