Actually i want to make a function for my user so that they can fatch any json data with super simplefied way. Thats why this function produce object variable just by calling object. Its searching for object and display its value.
I have made it.
Now i want to get the function return in a variable so that my user do whatever they want.
I am new in JavaScript so i cant figure out with the answer that already exist in this site. Thats why i post my problem. Plz Someone help me here with my code.
My progress is below:
function curl(x,y){let txt; var result; var rx = new RegExp(`["|" ]${y}[ "|" | " |"]:[ "|" | " |"|["](.+?)[}|"]`, 'g');
fetch(x).then(r => r.text()).then(t => {
t.match(rx).forEach(e => { var v = e.replace(rx, '$1'); txt += v + ',' });
var re = decodeURIComponent(JSON.parse('"' + txt.replace(/\"/g, '\\"') + '"'));
result = re.replace(/undefined|"|,\s*$/g,'').replace(/,,/g,'<br>');
alert(result);
});
}
curl('https://list.ly/api/v4/meta?url=http://google.com','images');
Now i want like this:
var data = curl('https://list.ly/api/v4/meta?url=http://google.com','images');
alert(data);