Fix example for responseHandling config via <meta> tag (#2715)

The current example throws this error:

  htmx.js:2914 SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)
    at JSON.parse (<anonymous>)
    at parseJSON (htmx.js:816:19)
    at getMetaConfig (htmx.js:4902:14)
    at mergeMetaConfig (htmx.js:4909:24)
    at HTMLDocument.<anonymous> (htmx.js:4917:5)

Co-authored-by: ekzyis <ekzyis@ekzy.is>
This commit is contained in:
ekzyis 2024-08-05 14:40:16 -05:00 committed by GitHub
parent 13b44b7897
commit e2b671d2f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -972,10 +972,17 @@ Using the [meta config](#configuration-options) mechanism for configuring respon
config:
```html
<meta name="htmx-config" content='{code:"204", swap: false}, // 204 - No Content by default does nothing, but is not an error
{code:"[23]..", swap: true}, // 200 & 300 responses are non-errors and are swapped
{code:"422", swap: true}, // 422 responses are swapped
{code:"[45]..", swap: false, error:true}, // 400 & 500 responses are not swapped and are errors'>
<meta
name="htmx-config"
content='{
"responseHandling":[
{"code":"204", "swap": false},
{"code":"[23]..", "swap": true},
{"code":"422", "swap": true},
{"code":"[45]..", "swap": false, "error":true}
]
}'
/>
```
If you wanted to swap everything, regardless of HTTP response code, you could use this configuration: