-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
función para obtener el menor precio #38
- Loading branch information
1 parent
0069a73
commit d932b62
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
d932b62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: