Skip to content

Commit

Permalink
función para obtener el menor precio #38
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelfdez99 committed Dec 7, 2020
1 parent 0069a73 commit d932b62
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions api/outlet.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
const data = require('./data.js')

async function aSeason(){
async function Price(){
var item = "";
var price = 1000;
for(let i in data.data.items){
if(data.data.items[i].season == "SPRING_SUMMER"){
if(data.data.items[i] < price)
price = data.data.items[i].price;
item = data.data.items[i];
}
}
return item;
}

module.exports = async (req,res) => {
try {
status: 200,
res.send(await aSeason())
} catch(error){
status: 500,
res.send(error)
}
if(Price() == ''){
status:404,
res.send('Error')
}else{
status:200,
res.send(await Price())
}
}

1 comment on commit d932b62

@vercel
Copy link

@vercel vercel bot commented on d932b62 Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.