BrainMinder/assets/static/js/htmx/ext/json-enc.js

12 lines
360 B
JavaScript
Raw Normal View History

2024-08-22 10:13:16 +02:00
htmx.defineExtension('json-enc', {
onEvent: function (name, evt) {
if (name === "htmx:configRequest") {
evt.detail.headers['Content-Type'] = "application/json";
}
},
encodeParameters : function(xhr, parameters, elt) {
xhr.overrideMimeType('text/json');
return (JSON.stringify(parameters));
}
});