#Need help deleting a post using axios

9 messages · Page 1 of 1 (latest)

mellow willow
#

Hello guys! Im creating a social media using next js, ive made the api aswell and it has this endpoint for deleting posts: DELETE http://localhost:3000/api/posts/123, where the number 123 is the post id, is there anyway i could show a delete button that only shows on posts posted by the user logged in, im using a bearer token system. Thanks in advance

undone tinselBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

      🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>

      ✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
      (if you don't see the option, try refreshing Discord with Ctrl + R)
lofty timber
#

@mellow willow If you want to show the delete button only to authenticated used..then firstly store the token in localstorage after user logged in and check if token available in local storage and show the button

mellow willow
#

@lofty timber how can i check if a token is available in the local storage?

mellow willow
lofty timber
#

Now for post u can check if token is available n valid then show button

mellow willow
#

but wouldnt that show on every post?