Skip to content

Commit

Permalink
Merge branch 'baseline' of https://github.com/bahrus/be-reformable in…
Browse files Browse the repository at this point in the history
…to baseline
  • Loading branch information
bahrus committed Nov 16, 2024
1 parent a84ce45 commit fd456a1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions be-reformable.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,33 @@ class BeReformable extends BE {
let url = pathBuilder.join('');
enhancedElement.action = url;
const {method} = enhancedElement;
const formData = new FormData(enhancedElement);
/**
* @type {BodyInit | undefined}
*/
let body;
switch(method.toLowerCase()){
case '':
case 'get':
case 'delete':
if(enhancedElement.method.toLowerCase() === 'get'){
const formData = new FormData(enhancedElement);

const queryString = new URLSearchParams(formData).toString();
url += '?' + queryString
}
break;
case 'put':
case 'post':
body = formData;
break;
}
/**
* @type {RequestInit}
*/
const fetchOptions = {
method,
headers
headers,
body
};

if(headerFields !== undefined){
Expand Down

0 comments on commit fd456a1

Please sign in to comment.