Skip to content
Permalink
Browse files

Add Function To Get Market Quotes From coinmarketcap

  • Loading branch information...
piavgh committed Feb 12, 2019
1 parent a63c0a9 commit b1dd9842b823811e744b509e0ea739d7226f4454
Showing with 19 additions and 0 deletions.
  1. +19 −0 services/coinmarketcap/getMarketQuotes.js
@@ -0,0 +1,19 @@
import axios from 'axios'

import { coinMarketCapAPI } from "../../config"

export const getMarketQuotes = async (baseTokenSymbol = null, quoteTokenSymbol = null) => {
try {
baseTokenSymbol = baseTokenSymbol || 'ETH'
quoteTokenSymbol = quoteTokenSymbol || 'TOMO'

const response = await axios.get(`${coinMarketCapAPI}/v1/cryptocurrency/quotes/latest?symbol=${baseTokenSymbol}&convert=${quoteTokenSymbol}`, {
headers: { 'X-CMC_PRO_API_KEY': process.env.COINMARKETCAP_API_KEY },
})

return response.data.data
} catch (err) {
console.log(err)
return null
}
}

0 comments on commit b1dd984

Please sign in to comment.
You can’t perform that action at this time.