Skip to content

Commit

Permalink
fix dupe ISBN error
Browse files Browse the repository at this point in the history
  • Loading branch information
ivyadam committed Dec 7, 2021
1 parent baa5b57 commit 9ce01ca
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 9ce01ca

Please sign in to comment.