ms.app.addPosthook({entity: 'ms.products', command: 'list'}, function(req, res, next) {
if(req.query && req.query.sort) return next()
var products = res.data && res.data.data;
if(!products) return next()
var shuffle = function (array) {
let currentIndex = array.length, randomIndex;
while (currentIndex != 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
return array;
}
shuffle(products)
next();
});