• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Node.js, Express 게시판 nodemon 에러가 자꾸 나네용..

nodemon 에러가 자꾸 나네용..

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #63907

    손예림
    참가자
    const express = require('express');
    const app = express();
    const bodyParser = require('body-parser');
    const MongoClient = require('mongodb').MongoClient;
    app.use(bodyParser.urlencoded({extended : true}));
    
    
    app.get('/pet', function(req, res){
    res.send('펫 쇼핑할 수 있는 페이지입니다.');
    });
    app.get('/beauty', function(req, res){
    res.send('뷰티용품 쇼핑 페이지임');
    })
    app.get('/', function(req, res){
    res.sendFile(__dirname + '/index.html')
    })
    app.get('/write', function(req, res){
    res.sendFile(__dirname + '/write.html')
    })
    app.post('/add', function(req, res){
    res.send('전송완료');
    console.log(req.body);
    })
    var db;
    MongoClient.connect('mongodb+srv://아이디와:비밀번호는 입력했습니당@프로젝트 명두요.xexqdky.mongodb.net/?retryWrites=true&w=majority', function(error, client){
    if (error) return console.log(error);
    db = client.db('todoapp');
    db.collection('post').insertOne('data' , function(error, result){
    console.log('저장완료');
     });
    app.listen(8080, function(){
    console.log('listening on 8080')
     });
    })
    
    
    server.js 파일입니당 
    강의를 들으면서 치고 있는데 insertOne() 저장할 때부터 Cannot create property '_id' on string 'data' 
    [nodemon] app crashed - waiting for file changes before starting...
    에러가 납니다 어떻게 바꿔야 할까요?ㅜㅜ
    #63930

    codingapple
    키 마스터
    insertOne뒤에는 object자료만 집어넣을 수 있습니다
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠