Skip to content

Commit

Permalink
Merge pull request #23 from ivyadam/main
Browse files Browse the repository at this point in the history
fix dupe ISBN error
  • Loading branch information
allisonglittle authored Dec 7, 2021
2 parents 32cd25a + b1241a7 commit 3a4dd38
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions library-express/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(){
}
}
});

/* Adds a title, redirects to the title page after adding */
router.post('/', function(req, res){
console.log(req.body);
Expand All @@ -41,13 +41,12 @@ module.exports = function(){
sql = mysql.pool.query(sql, inserts, function(error, results, fields){
if(error){
console.log(JSON.stringify(error));
res.write(JSON.stringify(error));
res.end();
res.send("<script>alert(\"Duplicate ISBN found. Unable to add new title.\"); window.location.href = \"/titles\"; </script>");
} else{
res.redirect('/titles');
}
});
});

return router;
}();

0 comments on commit 3a4dd38

Please sign in to comment.