You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
db.query("DELETE FROM blog_posts WHERE ($1)=id",[postId])
.then(()=>{
res.writeHead(302,{
location: "/"
});
// res.writeHead(200
res.end();
})
.catch(console.log);
}
This model function is sending a response, which isn't a good idea. The reason we separate our data access into separate functions is to ensure each bit of our app has a single responsibility. This model function is now much harder to test (you'd need to use Supertest or something, instead of just calling the function and seeing what it gives you back).
I'd really recommend making all your model functions just resolve with data, and handle the actual logic/response stuff in your handlers.
The text was updated successfully, but these errors were encountered:
week6-BGJK/src/model.js
Lines 89 to 99 in c967c93
This model function is sending a response, which isn't a good idea. The reason we separate our data access into separate functions is to ensure each bit of our app has a single responsibility. This model function is now much harder to test (you'd need to use Supertest or something, instead of just calling the function and seeing what it gives you back).
I'd really recommend making all your model functions just resolve with data, and handle the actual logic/response stuff in your handlers.
The text was updated successfully, but these errors were encountered: