Browse Source

Fix typos

main
anthony 4 years ago
parent
commit
f23bc6e44f
  1. 16
      index.js

16
index.js

@ -4,6 +4,8 @@ import axios from 'axios';
const app = fastify({logger: true});
// CAT FACTS
const CAT_API_ENDPOINT = "https://cat-fact.herokuapp.com";
const CAT_FACTS_COUNT = 3;
@ -11,16 +13,17 @@ async function fetch3CatFacts() {
const uri = `${CAT_API_ENDPOINT}/facts/random?amount=${CAT_FACTS_COUNT}`;
try {
const response = await axios.get(uri);
console.log()
return response.data.map(rep => rep.text);
} catch {
return null;
}
}
// FOX API
const FOX_API_ENDPOINT = 'https://randomfox.ca/floof';
async function fetchFowImage() {
async function fetchRandomFoxImage() {
try {
const response = await axios.get(FOX_API_ENDPOINT);
return response.data.image;
@ -29,9 +32,11 @@ async function fetchFowImage() {
}
}
// OFF DAYS
const DAYS_OFF_API_ENDPOINT = "https://date.nager.at"
async function fetchDaysOfPerCountry(country) {
async function fetchDaysOffPerCountry(country) {
if (country) {
return null;
@ -48,12 +53,11 @@ async function fetchDaysOfPerCountry(country) {
}
app.post('/', async (req, _res) => {
const countryCode = req.body?.countryCode;
const [foxPicture, catFacts, holidays] = await Promise.all([
fetchFowImage(),
fetchRandomFoxImage(),
fetch3CatFacts(),
fetchDaysOfPerCountry(countryCode)
fetchDaysOffPerCountry(countryCode)
])
return {

Loading…
Cancel
Save