|
|
@ -1,9 +1,28 @@ |
|
|
import fastify from 'fastify'; |
|
|
import fastify from 'fastify'; |
|
|
|
|
|
import axios from "axios"; |
|
|
// see axios doc on how to use it
|
|
|
// see axios doc on how to use it
|
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
|
|
|
|
const app = fastify({logger: true}); |
|
|
const app = fastify({logger: true}); |
|
|
|
|
|
|
|
|
|
|
|
const getCatFacts = async () => { |
|
|
|
|
|
const url ='https://cat-fact.herokuapp.com/facts/random?amount=3'; |
|
|
|
|
|
const {data} = await axios.get(url); |
|
|
|
|
|
data.forEach( d => console.log(d.text)); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getFoxImage = async () => { |
|
|
|
|
|
const url ='https://randomfox.ca/floof/'; |
|
|
|
|
|
const {data} = await axios.get(url); |
|
|
|
|
|
console.log(data.image); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getCountryHour = async () => { |
|
|
|
|
|
const url ='https://date.nager.at/api/v2/publicholidays/2021/CU'; |
|
|
|
|
|
const {data} = await axios.get(url); |
|
|
|
|
|
data.forEach( d => console.log(d.date)); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/', async (req, res) => { |
|
|
app.get('/', async (req, res) => { |
|
|
return { |
|
|
return { |
|
|
message: `Welcome to Node Babel with ${ |
|
|
message: `Welcome to Node Babel with ${ |
|
|
@ -22,3 +41,6 @@ const start = async () => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
start(); |
|
|
start(); |
|
|
|
|
|
getCatFacts(); |
|
|
|
|
|
getFoxImage(); |
|
|
|
|
|
getCountryHour(); |