Conversation
…r data and complete app.js
server.js
Outdated
| }) | ||
| }); | ||
|
|
||
| // app.get('api/motorcycleList', controllers.motorcycleList.index); |
There was a problem hiding this comment.
Looks correct, you can probably uncomment it, may or may not need to add a '/' in front of api
| @@ -0,0 +1,87 @@ | |||
| /*********** | |||
| * DATABASE * | |||
| ************/ | |||
There was a problem hiding this comment.
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 | ||
| } |
There was a problem hiding this comment.
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);
});
|
|
||
| $(document).ready(function(){ | ||
| console.log('app.js is loaded!'); | ||
| $.ajax({ |
There was a problem hiding this comment.
Looks good here, the process to grab data from the database goes from
- app.js, look for an ajax call
- look into server.js for a route that matches with method and url
- look at the route for a controller and function
- look into the controller for the function and add the logic to grab the data
- if you want to return JSON, you can do res.json(dataReturned) in your controller function or use success like you did here
mnfmnfm
left a comment
There was a problem hiding this comment.
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 | ||
| } |
| var mongoose = require('mongoose'), | ||
| Schema = mongoose.Schema; | ||
|
|
||
| const ProfileSchema = new Schema ({ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
Please