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

Loading…
Cancel
Save