-
This commit is contained in:
@@ -3,6 +3,7 @@ const router = express.Router();
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
res.send("Enter a recipe name in the url!");
|
||||
res.status(404);
|
||||
});
|
||||
|
||||
router.get("/:id", (req, res) => {
|
||||
|
@@ -1,36 +0,0 @@
|
||||
function saveRecipe() {
|
||||
const title = document.getElementById("title").value;
|
||||
const recipe = document.getElementById("recipe").value;
|
||||
|
||||
if (title && recipe) {
|
||||
const data = {
|
||||
title: title,
|
||||
recipe: recipe,
|
||||
};
|
||||
|
||||
const jsonString = JSON.stringify(data, null, 2);
|
||||
const blob = new Blob([jsonString], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const errorMsg = document.getElementById("errMsg");
|
||||
if (errorMsg) errorMsg.remove();
|
||||
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = title;
|
||||
a.click();
|
||||
|
||||
URL.revokeObjectURL(url);
|
||||
} else if (title === "" || recipe === "") {
|
||||
throwError("You have to fill in the title and recipe!");
|
||||
}
|
||||
}
|
||||
|
||||
function throwError(message) {
|
||||
const element = document.createElement("p");
|
||||
element.innerText = message;
|
||||
element.id = "errMsg";
|
||||
document.body.appendChild(element);
|
||||
|
||||
console.error(message);
|
||||
}
|
Reference in New Issue
Block a user