I am trying to render tradingview chart using tradingview charting library and using bitquery api for datafeed.
Chart is being displayed but there is no data on the chart.
I opened the inspect element and noticed this:
More specifically the part about RangeError: Invalid time value
I am assuming that's what's causing the chart to not load any candlestick data?
This is the section of the code in datafeed.js:
// This method is used by the charting library to get historical data for the symbol.
getBars: async(symbolInfo, resolution, from, to, onHistoryCallback, onErrorCallback, first) =>{
try{
if (resolution==='1D') {
resolution = 1440;
}
const response2 = await axios.post(Bitquery.endpoint, {
query: Bitquery.GET_COIN_BARS,
variables: {
"from": new Date(from).toISOString(),
"to": new Date(to).toISOString(),
"interval": Number(resolution),
"tokenAddress": symbolInfo.ticker
},
mode: 'cors',
headers: {
"Content-Type": "application/json",
"X-API-KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
})
const bars = response2.data.data.ethereum.dexTrades.map(el => ({
time: new Date(el.timeInterval.minute).getTime(), // date string in api response
low: el.low,
high: el.high,
open: Number(el.open),
close: Number(el.close),
volume: el.volume
}))
if (bars.length){
onHistoryCallback(bars, {noData: false});
}else{
onHistoryCallback(bars, {noData: true});
}
} catch(err){
console.log({err})
// onErrorCallback(err)
}
I am fairly new with tradingview charting library and JS, so I need suggestions to fix this.