forked from SpiderMath/Becoditive-API
-
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.
Signed-off-by: Momozor <[email protected]>
- Loading branch information
Momozor
committed
May 25, 2021
1 parent
9f27fb3
commit f33db43
Showing
57 changed files
with
10,874 additions
and
2,538 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
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,65 +1,62 @@ | ||
const Animals = require('../../models/animals') | ||
|
||
|
||
exports.cat = async(req, res, next) => { | ||
try{ | ||
const data = await Animals.find({animal : "cats"}) | ||
let randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image : randomData.image, | ||
fact: randomData.fact | ||
}) | ||
}catch(error){ | ||
console.log(error) | ||
res.status(500).json({ | ||
"error": error | ||
}) | ||
} | ||
exports.cat = async (req, res, next) => { | ||
try { | ||
const data = await Animals.find({ animal: 'cats' }) | ||
const randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image: randomData.image, | ||
fact: randomData.fact | ||
}) | ||
} catch (error) { | ||
console.log(error) | ||
res.status(500).json({ | ||
error: error | ||
}) | ||
} | ||
} | ||
|
||
exports.bird = async(req, res, next) => { | ||
try{ | ||
const data = await Animals.find({animal : "birds"}) | ||
let randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image : randomData.image, | ||
fact: randomData.fact | ||
}) | ||
}catch(error){ | ||
res.status(500).json({ | ||
"error": error | ||
}) | ||
} | ||
|
||
exports.bird = async (req, res, next) => { | ||
try { | ||
const data = await Animals.find({ animal: 'birds' }) | ||
const randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image: randomData.image, | ||
fact: randomData.fact | ||
}) | ||
} catch (error) { | ||
res.status(500).json({ | ||
error: error | ||
}) | ||
} | ||
} | ||
|
||
exports.dog = async(req, res, next) => { | ||
try{ | ||
const data = await Animals.find({animal : "dogs"}) | ||
let randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image : randomData.image, | ||
fact: randomData.fact | ||
}) | ||
}catch(error){ | ||
res.status(500).json({ | ||
"error": error | ||
}) | ||
} | ||
exports.dog = async (req, res, next) => { | ||
try { | ||
const data = await Animals.find({ animal: 'dogs' }) | ||
const randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image: randomData.image, | ||
fact: randomData.fact | ||
}) | ||
} catch (error) { | ||
res.status(500).json({ | ||
error: error | ||
}) | ||
} | ||
} | ||
|
||
exports.panda = async(req, res, next) => { | ||
try{ | ||
const data = await Animals.find({animal : "pandas"}) | ||
let randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image : randomData.image, | ||
fact: randomData.fact | ||
}) | ||
}catch(error){ | ||
res.status(500).json({ | ||
"error": error | ||
}) | ||
} | ||
|
||
} | ||
exports.panda = async (req, res, next) => { | ||
try { | ||
const data = await Animals.find({ animal: 'pandas' }) | ||
const randomData = data[Math.floor(Math.random() * data.length)] | ||
res.status(200).json({ | ||
image: randomData.image, | ||
fact: randomData.fact | ||
}) | ||
} catch (error) { | ||
res.status(500).json({ | ||
error: error | ||
}) | ||
} | ||
} |
Oops, something went wrong.