Skip to content

Commit

Permalink
got delete to work with getting postId
Browse files Browse the repository at this point in the history
  • Loading branch information
EliNygard committed May 20, 2024
1 parent 288d800 commit ba564c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions javascript/api/deletePost.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { API_BASE, API_ID, API_NAME, API_POSTS } from "./constantAPI.mjs";
import { API_BASE, API_NAME, API_POSTS } from "./constantAPI.mjs";

export function deletePost() {
export function deletePost(postId) {
// get id of selected post ✅
// get the url ✅

Expand All @@ -12,8 +12,9 @@ export function deletePost() {
// const API_NAME = `/${name}`;

const token = localStorage.getItem('accessToken');
console.log(postId);

fetch(API_BASE + API_POSTS + API_NAME + API_ID, {
fetch(API_BASE + API_POSTS + API_NAME + `/${postId}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token}`,
Expand Down

0 comments on commit ba564c8

Please sign in to comment.