@Nghĩa-Nguyễn said in How to delete file using api:
var http = new XMLHttpRequest();
var url = window.location.origin + '/api/v3/files';
http.open('DELETE', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send({
path: f
});
A nice version, which also automatically include the CSRF Token (@baris why didn't you mention it?):
const [api] = await app.require(['api']);
api.del('/api/v3/files', { path: "XXX" })