Commit 0d810859 by Иван Кубота

fix

parent 00ece798
Pipeline #541 failed with stage
...@@ -7,6 +7,7 @@ let cats = [ ...@@ -7,6 +7,7 @@ let cats = [
module.exports = { module.exports = {
'/api/new': { '/api/new': {
options: {},
method: 'GET', method: 'GET',
summary: 'Get list of new cards', summary: 'Get list of new cards',
fn: async function(args) { fn: async function(args) {
...@@ -17,15 +18,15 @@ module.exports = { ...@@ -17,15 +18,15 @@ module.exports = {
method: 'GET', method: 'GET',
summary: 'Get card details', summary: 'Get card details',
options: { options: {
categoryID: {required: true, description: 'ID of card category', type: Number}, categoryID: { required: true, description: 'ID of card category', type: Number },
cardID: {required: true, description: 'ID of card in category', type: Number} cardID: { required: true, description: 'ID of card in category', type: Number }
}, },
fn: async function(args) { fn: async function( args ){
let searched = Object.values(data.products).filter(p=>p.id===args.cardID && p.category_id === args.categoryID); let searched = Object.values( data.products ).filter( p => p.id === args.cardID && p.category_id === args.categoryID );
if(searched.length){ if( searched.length ){
return searched[0]; return searched[ 0 ];
}else{ }else{
throw new Error('No matched product') throw new Error( 'No matched product' )
} }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment