Skip to content

Conversation

@CongoCash
Copy link

Please

server.js Outdated
})
});

// app.get('api/motorcycleList', controllers.motorcycleList.index);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct, you can probably uncomment it, may or may not need to add a '/' in front of api

@@ -0,0 +1,87 @@
/***********
* DATABASE *
************/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like this to grab all your models/database tables:

var db = require('../models');

// GET /api/albums
function index(req, res) {
// send back all albums as JSON
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like this to grab data from your database, probably need to add data into the database first or seed it?

db.Profile.find({}, function(err, dataReturned) {
res.json(dataReturned);
});

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


$(document).ready(function(){
console.log('app.js is loaded!');
$.ajax({
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here, the process to grab data from the database goes from

  1. app.js, look for an ajax call
  2. look into server.js for a route that matches with method and url
  3. look at the route for a controller and function
  4. look into the controller for the function and add the logic to grab the data
  5. if you want to return JSON, you can do res.json(dataReturned) in your controller function or use success like you did here

Copy link

@mnfmnfm mnfmnfm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you had trouble getting any part of your API working--this is really concerning. This project isn't close to meeting expectations.

// GET /api/albums
function index(req, res) {
// send back all albums as JSON
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

var mongoose = require('mongoose'),
Schema = mongoose.Schema;

const ProfileSchema = new Schema ({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is data about a motorcycle; why is it in a file called Profile?

});

//Need to resolve this issue here, when I run node seed.js
//I'm getting an error that .remove() is undefined
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because what you export is called Profile, not List. An even better name might be Motorcycle.


<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="weight">Max Torque:</label>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "for" here makes it obvious that this was copy/pasted and never tested

<div class="form-group">
<label class="col-md-4 control-label" for="engineDisplacement">Engine Displacement (Cylinder Capacity or Cubic Centimeters):</label>
<div class="col-md-4">
<textarea class="form-control" id="engineDisplacement" name="engine displacement">for ex: 999cc</textarea>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names shouldn't be multiple words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants