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

home2 게시판 Node.js, Express 게시판 SyntaxError: Unexpected end of input 이런 오류가 뜹니다

SyntaxError: Unexpected end of input 이런 오류가 뜹니다

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

    박신희
    참가자
    const express = require('express')
    const app = express()
    const MongoClient = require('mongodb').MongoClient
    app.set('view engine', 'ejs')
    app.engine('ejs',require('ejs').__express)
    app.use(express.urlencoded({ extended: true }));
    var db;
    MongoClient.connect('mongodb+srv://admin:admin1234!@cluster0.unkjl34.mongodb.net/?retryWrites=true&w=majority',
        function(에러, client){
        if (에러) return console.log(에러)
        db=client.db('todoapp')
        db.collection('post').insertOne({이름:'Park',_id:100},function(에러,client){
            console.log('저장완료')
        });
        app.listen(8081, function() {
            console.log('listening on 8081') })})
        //여기 이하는 쓸데없는 app.get 이런 코드들
        app.get('/', function(요청, 응답) {
            응답.sendFile(__dirname +'/index.html')})
        // 누군가가 /pet으로 방문을 하면// pet 관련 안내문을 띄워주자
        app.get('/pet',function(요청,응답){
            응답.send('펫 용품 쇼핑할 수 있는 페이지 입니다.')});
        app.get('/beauty',function(요청,응답){
            응답.send('뷰티 용품 쇼핑할 수 있는 페이지 입니다.')});
        app.get('/write',function(요청,응답){
            응답.sendFile(__dirname + '/write.html')});
        app.get('/list',function(요청,응답){
            db.collection('post').find().toArray(function(에러, 결과){
                console.log(결과)
                응답.render('list.ejs',{posts:결과});
        });
        //디비에 저장된 post라는 collection안의 모든 데이터를 꺼내주세요
        app.post('/add', function(요청, 응답){
            응답.send('전송완료');
            db.collection('post').insertOne( { 제목 : 요청.body.title, 날짜 : 요청.body.date } , function(에러,결과){
                console.log('저장완료')
            });
        });
    #87087

    codingapple
    키 마스터
    insertOne 소괄호가 안닫힌듯요
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 호 / 개인정보관리자 : 박종흠