Skip to content

Commit

Permalink
Update agstransaction.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tonnyandersson committed Nov 23, 2023
1 parent 110e18a commit 8602ab2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/controls/editor/agstransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,31 @@ function agsTransaction(transObj, layerName, viewer) {
}
}

function getFormData(object) {
const formData = new FormData();
Object.keys(object).forEach(key => formData.append(key, object[key]));
return formData;
}

const cb = {
update: updateSuccess,
insert: insertSuccess,
delete: deleteSuccess
};
types.forEach((type) => {
if (transObj[type]) {
const u = source.url.slice(-1) === '/' ? source.url : `${source.url}/`;
const i = `${id}`.slice(-1) === '/' ? id : `${id}/`;
const url = u + i + urlSuffix[type];
const url = `${source.url}/${id}/${urlSuffix[type]}`;

const data = writeAgsTransaction(transObj[type], {
projection,
type
});
fetch(url, {
method: 'POST',
body: data
}, cb[type])
body: getFormData(data)
})
.then(res => res.json())
.then(json => json)
.then(json => cb[type](json))
.catch(err => error(err));
}
});
Expand Down

0 comments on commit 8602ab2

Please sign in to comment.