Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
React, Fetch sending empty body

So I have a problem about sending a request. Body is not empty at all since I can log it. But somehow when I make a request, the body is empty. It was weird so I copied a working request code that didn't send an empty body, guess what? Body empty. I have cors enabled.

empty body === second

image

  const handleSubmit = async (e) => {
    e.preventDefault()
    try {
      let data = new FormData()
      data.set("key", "")
      data.append("image", groupPFP.file)

      const res = await fetch("https://api.imgbb.com/1/upload", {
        method: "POST",
        body: data,
      })

      const parseRes = await res.json()

      if (parseRes.status === 200) {
        const imgbbLink = parseRes.data.display_url

        const resData = { groupProfileImage: imgbbLink, groupName, groupAbout }

        const res = await fetch("http://localhost:5000/api/group/create", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            JwtToken: localStorage.getItem("JwtToken"),
          },
          body: JSON.stringify(resData),
        })

        const parseResPFP = await res.json()

        if (parseResPFP.status === 429) {
          return toast.error("Too Many Requests, try again later")
        }

        toast.success("Group created successfully")
      }
    } catch (error) {
      console.error(error)
    }
  }

No errors

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!