我需要创建按钮来删除对象。用于delte的REST intefrace是... / rest / product / idofproduct
我正在使用带有Fetch API的类
acquireLockAndRunOnNewThread(() -> {
acquiredLock=true;
continueWithOtherStuff();
}
//do not continue until the lock is acquired
while(acquiredLock==false){
Thread.sleep(100);
}
continueWithOtherStuffThatAlsoAcquiresALockAtSomePointInTime()
比我有一个fucnction.js,我有
class App{
deleteProduct(id){
return fetch('http://localhost:8080/productdb-0.1/rest/product/'+ id , {
method: 'delete'
})
.then(r=> r.json());
}
}
我正在尝试将其映射到
内的按钮上 let deleteApp = new App();
let remove = document.getElementById('productList');
remove.addEventListener('submit',function (e) {
e.preventDefault();
let id = document.getElementById('delete').getAttribute('data');
})
但它不起作用,不知道可能出现什么问题。
感谢您的任何建议:)