Skip to content

Commit

Permalink
name chang on const
Browse files Browse the repository at this point in the history
  • Loading branch information
EliNygard committed May 23, 2024
1 parent e150e4a commit fb7d1e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions javascript/generateHtml/manageTableHtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function generateTableHtml(post) {
});

const queryParamsString = queryParams.toString();
console.log(queryParamsString);
window.location.href = `./edit.html?${queryParamsString}`;
});

Expand Down
24 changes: 14 additions & 10 deletions javascript/ui/editPost.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ const form = document.querySelector("form");
const parameterString = window.location.search;
const searchParams = new URLSearchParams(parameterString);
const title = searchParams.get("title");
console.log(title);
const body = searchParams.get("body");
const imgUrl = searchParams.get("imgUrl");
console.log(imgUrl);
const imgAlt = searchParams.get("imgAlt");
const category = searchParams.get("category");

const titleInput = document.getElementById("title");
titleInput.value = title;
console.log(titleInput);
const bodyInput = document.getElementById("body");
bodyInput.value = body;
const imgUrlInput = document.getElementById("img-url");
imgUrlInput.value = imgUrl;
console.log(imgUrlInput);
const imgAltInput = document.getElementById("img-alt");
imgAltInput.value = imgAlt;
const categorySelect = document.getElementById("category");
Expand All @@ -31,25 +35,25 @@ form.addEventListener("submit", function (event) {
event.preventDefault();

// Get values from form inputs
const title = document.getElementById("title").value;
const body = document.getElementById("body").value;
const imgUrl = document.getElementById("img-url").value;
const imgAlt = document.getElementById("img-alt").value;
const category = document.getElementById("category").value;
const editedTitle = document.getElementById("title").value;
const editedBody = document.getElementById("body").value;
const editedImgUrl = document.getElementById("img-url").value;
const editedImgAlt = document.getElementById("img-alt").value;
const editedCategory = document.getElementById("category").value;

const token = localStorage.getItem("accessToken");

// Construct the request options
const requestOptions = {
method: "PUT",
body: JSON.stringify({
title: title,
body: body,
title: editedTitle,
body: editedBody,
media: {
url: imgUrl,
alt: imgAlt,
url: editedImgUrl,
alt: editedImgAlt,
},
tags: [category],
tags: [editedCategory],
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
Expand Down

0 comments on commit fb7d1e6

Please sign in to comment.