Skip to content

Instantly share code, notes, and snippets.

// try this online: https://codepen.io/Xiwi/pen/jOEXJRa?editors=0010
// (don't forget to open the console)
const getData = function(url) {
axios.get(url)
.then(function(response){
let follow = response.data.follow;
if (follow) {
follow = follow.replace('challenge?', 'challenge.json?');
console.log(follow);
// First try I was detecting if it was an array or not and create some loops
// if so, but I thought on an easier way to avoid some recursivity
const fixArray = function(array) {
const arrayString = array.toLocaleString(); // "1,2,3..."
const fixedArray = arrayString.split(',').map(function(item) {
return parseInt(item, 10);
});
console.log(fixedArray);