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)