Skip to content

Conversation

@CamCode9
Copy link
Owner

Have successfully implemented func to return article by id on GET request. When trying to implement err handling the query in article.models did not throw an error despite being invalid id, instead returned an empty array. Let me know if I should implement the error handling differently to how I have here

});
test("400: invalid article", async () => {
const result = await request(app).get("/api/articles/99995").expect(400);
expect(result.body.msg).toBe("Bad request");

Choose a reason for hiding this comment

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

So think about this... Is this a 400? It isn't an invalid article ID as it's a number, so should return a 404. You mentioned up there about returning an empty array - could you do something with that to reject the promise?

A 400 - bad request - would be eg an invalid data type like 'cheese'

@@ -0,0 +1,13 @@
const db = require("../db/connection");

exports.selectAllArticles = async (article_id) => {

Choose a reason for hiding this comment

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

This function should now no longer be called selectAllArticles - what should it be?

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.

3 participants