How I generated a random response from a API

danielarmbruster0314 - Mar 10 '22 - - Dev Community
       function firstFetch(){
        fetch('url')
        .then((resp) => resp.json())
        .then((data) => grabRandomId(data));
    };
function grabRandomId(arry){
    let newId = Math.floor((Math.random() * arry.length) + 1);
            fetch(`url/${newId}`)
            .then((resp) => resp.json())
            .then((data) => console.log(data));
        };

Enter fullscreen mode Exit fullscreen mode

Any critiques on this are more than welcome

. . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player