we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "mixpanel api data parsing"
Elena
01 Jan 2020
1      const regex = /}}/ig
2      const commaEndOfObjects = response.data.replace(regex, '}},');
3      const lastCommaToRemove = commaEndOfObjects.lastIndexOf('}},') + 2
4      const removeLastComma = commaEndOfObjects.slice(0, lastCommaToRemove) + commaEndOfObjects.slice(lastCommaToRemove +1);
5      const onlySingleQuotes = removeLastComma.replace(/'/g, '"');
6      const insideArray = `[${onlySingleQuotes}]`
7      const result = JSON.parse(insideArray)