I am trying to pull data from the database and display it in my app. Every variable is pulling except for firstPingPrice. I am getting either an undefined or NAN result.
const parsePing = (str) => {
const qoutePattern = /"(.*?)"/g;
const pingStr = str.match(qoutePattern)
const pings = [];
pingStr.forEach(i => {
if (i != '"resu"' && i != null && !(String(i).includes('<'))) {
i = i.split('"')[1].split('|')
let ticker = i[0] + 'BTC'
let ping = {
symbol: i[0],
market: 'BTC',
ticker: ticker,
ticker_slash: i[0] + '/' + 'BTC',
exchange: 'binance',
timestamp: i[7],
ping_info: {
pings: Number(i[1]).valueOf(),
net_vol_btc: Number(i[2]).valueOf(),
net_vol_per: i[3],
net_vol_per_num: Number(String(i[3]).split('%')[0]).valueOf(),
recent_total_vol_btc: Number(i[4]).valueOf(),
recent_volume_percentage: i[5],
recent_volume_percentage_num: Number(String(i[6]).split('%')[0]).valueOf(),
recent_net_volume: Number(i[6]),
first_ping_price: Number(i[8])
},
}
pings.push(ping)
}
})
return pings
} I believe this is the string. I added the firstPingPrice and assigned it i8.... I don't know if that's correct though. The data is going into the db correctly as a number and I am trying to display as a number in my app.
const parsePing = (str, exchange) => {
const qoutePattern = /"(.*?)"/g;
const pingStr = str.match(qoutePattern)
const pings = [];
pingStr.forEach((i) => {
if (i != '"resu"' && i != null && !(String(i).includes('<'))) {
i = i.split('"')[1].split('|')
let ticker = i[0] + 'BTC'
let ping = {
symbol: i[0],
market: 'BTC',
ticker: ticker,
exchange: exchange,
date: new Date().toLocaleDateString('en-US'),
info: {
pingNum: Number(i[1]),
netVolBTC: Number(i[2]),
netVolPer: i[3],
netVolPerNum: Number(String(i[3]).split('%')[0]),
recentTotalVolBTC: Number(i[4]),
recentVolPer: i[5],
recentVolPerNum: Number(String(i[6]).split('%')[0]),
recentNetVol: Number(i[6]),
btcPrice: '',
coinHigh: '',
coinLow: '',
dailyVol: '',
dailyPriceChange: '',
firstPingPrice: Number(i[8]),
}
}
pings.push(ping)
}
})
return pings
} enter code here