ga-wdi-exercises/project4

index issue - haven't changed index.js much yet :(

Closed this issue · 14 comments

HI! I'm getting this error:
proxyConsole.js:56 ./src/index.js
Module build failed: Error: Cannot read config file: /Users/daniellefricke/wdi/projects/Vacay2/vacay-app/node_modules/eslint-config-react-app/index.js
Error: ENOENT: no such file or directory, open '/Users/daniellefricke/wdi/projects/Vacay2/vacay-app/node_modules/eslint-config-react-app/index.js'
Referenced from:
at Array.reduceRight (native)

So far, I've only removed the serviceworker and favicon from the original file but I'm getting this angry error.

Here is my index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';


ReactDOM.render(<App />, document.getElementById('root'));

Any idea what I'm missing?

This is happening when you run npm start?

It is showing me the same error as above. It was running and showing me the React landing site...

does yarn start yield the same result?

I'm thinking this has to do with deleting the serviceWorker, which is what is freeing you from refreshing. If the above doesn't work, I would create a new project with create-react-app and paste in the code you have.

it's possible yarn install might clear up the error as well.

Oh this makes me sad. This will be the 4th time I've restarted today! Gotta start somewhere I guess :). I'll let you know how it goes....

It was yarn. Now its 'working'

New problem! My seeds won't seed. Its saying it cannot read 'push' of undefined but as far as I can see, its defined! Here is my seeds doc:

var mongoose = require("./schema");

var Blog = mongoose.model("Blog");
var Comment = mongoose.model("Comment");

Blog.remove({}, function(err){
  console.log(err)
});

Comment.remove({}, function(err){
  console.log(err)
});

var blog1 = new Blog({title: "Rome, Florence and Venice, Italy - So much pasta!!!", traveler: "Danielle F.", country: "Italy", when: "Fall 2016", bookingInfo:"lorem ipsum", activityInfo: "lorem ipsum", rentalInfo:"lorem ipsum", foodInfo:"lorem ipsum", additionalInfo:"lorem ipsum", images:["https://flic.kr/p/WPWPb6", "https://flic.kr/p/WPWPuH", "https://flic.kr/p/WCezHZ", "https://flic.kr/p/WLg5SL"]})
var blog2 = new Blog({title: "Sayulita, Mexico - Tacos, Cerveza, and Surf!!!", traveler: "Danielle F.", country: "Mexico", when: "Spring 2017", bookingInfo:"lorem ipsum", activityInfo: "lorem ipsum", rentalInfo:"lorem ipsum", foodInfo:"lorem ipsum", additionalInfo:"lorem ipsum", images:["https://flic.kr/p/WPWQog", "https://flic.kr/p/WCez8k", "https://flic.kr/p/WCez4T", "https://flic.kr/p/WCez1B" ]   })

var comment1 = new Comment({comment:"That old Fiat is so cool!", name:"Steve K."})
var comment2 = new Comment({comment:"Your vacation looks awesome!", name:"Bethany F."})

var blogs = [blog1, blog2]
var comments = [comment1, comment2]

blogs.forEach((blog, i) => {
  blog.comments.push(comments[i], comments[i+1])
  blog.save((err,post) => {
    if (err){
      console.log(err)
    } else {
      console.log(post);
    }
  })
})

can you post the code in your schema.js file?

What I'd be looking for there would the comments property of the Blog mongoose model.

var mongoose = require("mongoose");
mongoose.connect('mongodb://localhost/vacay');

var BlogSchema = new mongoose.Schema(
  {
    title: String,
    traveler: String,
    country: String,
    when: String,
    bookingInfo: String,
    activityInfo: String,
    rentalInfo: String,
    foodInfo: String,
    additionalInfo: String,
    images: []
  })

var CommentSchema = new mongoose.Schema(
  {
    comment: String,
    name: String,
    reviews: [BlogSchema]
  })

  mongoose.model("Blog", BlogSchema);
  mongoose.model("Comment", CommentSchema);


  // Now that we're connected, let's save that connection to the database in a variable.
  var db = mongoose.connection;

  // Will log an error if db can't connect to MongoDB
  db.on('error', err => {
    console.log(err);
  });

  // Will log "database has been connected" if it successfully connects.
  db.once('open', () => {
    console.log("database has been connected!");
  });

  module.exports = mongoose;

schema.js

Is it because the key in comment schema is called reviews and not blog?

Exactly! You should have comments on Blog. In your Schema you are defining what properties a model has.

I misread your comment as first, but to reiterate, BlogSchema should have a comments key that references CommentSchema and not the other way around.

Closing for now, let me know if you are still having this issue.