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

fix

parent 00ece798
Pipeline #541 failed with stage
......@@ -7,6 +7,7 @@ let cats = [
module.exports = {
'/api/new': {
options: {},
method: 'GET',
summary: 'Get list of new cards',
fn: async function(args) {
......@@ -15,17 +16,17 @@ module.exports = {
},
'/api/card_info/:categoryID/:cardID': {
method: 'GET',
summary: 'Get card details',
options: {
categoryID: {required: true, description: 'ID of card category', type: Number},
cardID: {required: true, description: 'ID of card in category', type: Number}
summary: 'Get card details',
options: {
categoryID: { required: true, description: 'ID of card category', type: Number },
cardID: { required: true, description: 'ID of card in category', type: Number }
},
fn: async function(args) {
let searched = Object.values(data.products).filter(p=>p.id===args.cardID && p.category_id === args.categoryID);
if(searched.length){
return searched[0];
fn: async function( args ){
let searched = Object.values( data.products ).filter( p => p.id === args.cardID && p.category_id === args.categoryID );
if( searched.length ){
return searched[ 0 ];
}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