Commit 84fefbb90ae94d9d6462ec8b75099b29ed3ee5cf

Authored by Adhidarma Hadiwinoto
1 parent a1188b251d
Exists in master

APISERVER: router-product gagal jika produk yg ingin dihapus tidak ada.

Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff

api-server/router-products.js
... ... @@ -60,6 +60,15 @@ function pageDel(req, res, next) {
60 60 const product = req.params.product.trim().toUpperCase();
61 61 config.products.map(function(x) { return x.toUpperCase(); });
62 62 const idx = config.products.indexOf(product);
  63 + if (idx <= 0) {
  64 + res.json({
  65 + method: '/products/del',
  66 + error: true,
  67 + error_msg: 'Product to delete does not exist on old product list'
  68 + });
  69 +
  70 + return;
  71 + }
63 72 config.products.slice(idx, 1)
64 73  
65 74 matrix.config_is_dirty = true;