Skip to content

Using PUT to Create a Resource #3013

Answered by Telroshan
PaulMansour asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, the doc indeed uses GET/POST, but that's simply because they are the most common & straightforward methods to showcase the library. It doesn't matter whether you use POST, PUT or PATCH, htmx will work the same.

The only thing you need to be aware of regarding methods is that, by default, GET and DELETE will have the parameters sent as URL encoded params, while POST/PUT/PATCH will have the values in the request body. This can be configured btw (see htmx.config.methodsThatUseUrlParams)

As for your usecase, htmx indeed doesn't provide any built-in way to handle dynamic URLs. The URLs in hx-post, hx-put etc. are parsed once when htmx processes the element, but not evaluated for each requ…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PaulMansour
Comment options

Answer selected by PaulMansour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants