Changing HTML/Express.js setup from POST to PUT?

280 views Asked by At

I have a function that works perfectly fine but I realized I'm using a POST function when it's probably proper to use PUT.

I switched app.post('/word', docType, function (req. res) { to app.put

Then in the html I switched:

<form action="/mediaDev/word" method="post" enctype="multipart/form-data">

to: method="put"

After making this change I end up getting 502 Bad Gateway.

Is there a crucial difference between POST and PUT that I'm missing here?

1

There are 1 answers

2
sdgluck On BEST ANSWER

Have you inspected the actual request being made? It is probably a GET.

See "Using PUT method in HTML form" for more information...

According to the HTML standard, you can not. The only valid values for the method attribute are get and post, corresponding to the GET and POST HTTP methods. <form method="put"> is invalid HTML and will be treated like <form>, i.e. send a GET request.

EDIT: On second thought I'm not certain why this would mean you get a 502 Bad Gateway, however I will leave this answer as I believe it is still useful.