-
Notifications
You must be signed in to change notification settings - Fork 699
onSubmit method #419
Copy link
Copy link
Closed
Labels
Description
I implemented the onSubmit method, these are the two methods that can be used, what do they think of implementing the project?
onSubmitXHR: function(cmd, url, record) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
return JSON.parse(xhr.responseText);
}
};
xhr.send(JSON.stringify({ cmd: cmd, record }));
},
onSubmit: function(cmd, url, record) {
(async () => {
const rawResponse = await fetch(url, {
method: "POST",
credentials: "include",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({ cmd: cmd, record })
}).catch(function(error) {
console.log("Request failed", error);
});
const content = await rawResponse.json();
})();
},
Reactions are currently unavailable