JavaScript fetch using formData
var formData = new FormData();
formData.append('cost', cost);
formData.append('id', id);
fetch('stock_log/update_purchase_price', {
method: 'POST',
body: formData
})
.then(function(response) {
let result = response.json();
result.then(function (res) {
console.log(res);
})
});