search

Home  >  Q&A  >  body text

405 error encountered when using Fetch POST data to the server in Express and Node - looking for a solution

I'm using Express and Node. Use Fetch to POST some data to the server. I'm getting a 405 error. I don't know how to solve this problem.

P粉311423594P粉311423594265 days ago464

reply all(2)I'll reply

  • P粉043432210

    P粉0434322102024-04-02 20:14:38

    From what I can see in the screenshot, your node application is running on port 3000, but the error on the console indicates that you are getting a 405 error on localhost, but the port 5501.

    Is it possible that you are trying to access the wrong URL?

    reply
    0
  • P粉256487077

    P粉2564870772024-04-02 10:35:56

    Just get the node app from "app.listen" by editing:

    fetch('api', options)
    

    to

    fetch('http://localhost:3000/api', options)
    

    index2.html Line 27

    reply
    0
  • Cancelreply