Skip to content

#828 JSON Parse Error for Image Upload #858

Discussion options

You must be logged in to vote

Apart from that I found the following issues in your code.

  1. You are saving the entire response from Cloudinary to image, which could is an object with multiple pieces of data, but you never actually use the URL for the image that Cloudinary returns. Instead, you are using a placeholder image "/placeholder.jpg" when adding a new remedy.

➡️ Extract the url from the Cloudinary response const { url } = await response.json(); This URL is what we need to display the uploaded image. Then use this url as the value for imageUrl in the remedyData. This ensures that the correct image is displayed when you add or edit a remedy.

async function handleSubmit(event) {
    event.preventDefault();

    const

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JessicaLoers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants