Skip to content

Malu's API gets Reviewed#30

Open
MaluPalu wants to merge 15 commits intoSF-WDI-LABS:masterfrom
MaluPalu:master
Open

Malu's API gets Reviewed#30
MaluPalu wants to merge 15 commits intoSF-WDI-LABS:masterfrom
MaluPalu:master

Conversation

@MaluPalu
Copy link

@MaluPalu MaluPalu commented Sep 5, 2017

Id like some feedback on some ideas to render page differently after I submit a form:

Id like some feedback on my back end CRUD functions and how I can use different more efficient code:

Id like some feedback on any DRY code you find:

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.

If your app were displaying updates to the data in single-page style, rather than by refreshing, this would be an excellent app--you're doing well, but I wish you had found a solution other than refreshing.

@@ -0,0 +1 @@
This is my documentation!
Copy link

Choose a reason for hiding this comment

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

haha, OK! But your documentation should be in your README.md file.

base_url: 'https://evening-beach-72520.herokuapp.com/',
endpoints: [
{method: "GET", path: "/api", description: "Describes all available endpoints"},
{method: "GET", path: "/api/profile", description: "Describes all available endpoints"},
Copy link

Choose a reason for hiding this comment

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

Your profile doesn't describe available endpoints, it describes you!

}

// GET /api/cliffs/:cliffId
function retrieve(req, res) {
Copy link

Choose a reason for hiding this comment

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

unused function. you can get rid of this.

// DELETE /api/cliffs/:cliffId
function destroy(req, res) {
console.log(req.params.id);
db.Cliff.findByIdAndRemove(req.params.id, (err, Cliff) => {
Copy link

Choose a reason for hiding this comment

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

Usually, you'd use lower-case cliff for the parameter name.

}
let response = {
message: "Cliff successfully deleted",
}
Copy link

Choose a reason for hiding this comment

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

Indentation 😭

url: 'api/cliffs',
data: $(this).serialize(),
success: function() {
window.location = '/'
Copy link

Choose a reason for hiding this comment

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

😭

Copy link

Choose a reason for hiding this comment

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

You could, instead, just render one cliff's worth of data, for the cliff you just saved.

nearestCity: String,
gpsCoords: String,
height: String,
acessibility: String,
Copy link

Choose a reason for hiding this comment

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

You're missing a c in accessibility--that's why it never saves correctly.

@@ -1,15 +1,15 @@
// This file allows us to seed our application with data
Copy link

Choose a reason for hiding this comment

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

It would be great if your seed file actually did something!


app.post('/api/cliffs/:id', controllers.cliffs.create);

app.get('/api/cliffs/:id', controllers.cliffs.retrieve);
Copy link

Choose a reason for hiding this comment

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

You don't use this and could remove it.


<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="nearestCity">Nearest City</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 attribute of the label needs to match the id of the input it's for, not the name. You should update the id of the input below this to be nearestCity.

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