I am trying to call CoinMarketCap's public API but it always fails with following error:
error occured Error: getaddrinfo ENOTFOUND api.coinmarketcap.com api.coinmarketcap.com:443
When I call the URL from the browser it returns the result instantly. The code is pretty simple:
const functions = require('firebase-functions');
const axios = require('axios');
exports.getBtcPrice = functions.https.onRequest((req, res) => {
axios.get('https://api.coinmarketcap.com/v1/ticker/bitcoin')
.then( (response) => {
console.log(response);
res.send("data received");
})
.catch((error) => {
console.log(error);
res.send("error occured "+ error)
});
});