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

251
Views
Why does my POST request get a 404 error while GET works fine?

I'm having issues sending post requests. Whenever I try and send a post request to localhost:5000/api it gives me this error "POST http://localhost:5000/api 404 (Not Found)" but whenever I do a get request it gives me no errors and works perfectly.

const createPost = async () => {
    let res = await axios.post("http://localhost:5000/api", {"id" : 4, "name" : "this was posted by code :)"})
    console.log(res)
  }

  useEffect(() => {
    axios.get("http://localhost:5000/api").then(res => {
      setBackendData(res.data)
    }).catch(err => {
      console.log(err)
    })
  }, [])

If you need anymore of my code please tell me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your backend has been written specifically without support for post. If you want, you could read this w3schools article on what different http methods exist. In the modern age, it's all semantic so what api endpoints you choose is up to you (post is generally recommended for security reasons though).

If you want your backend to support post, change your code to use app.post instead of app.get.

about 4 years ago · Juan Pablo Isaza Report
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!