混响两个异步调用

I am calling the twitch TV API to get users info from one endpoint and I want also to call another endpoint in the same API to check if those users are streaming live or not, but only if the first ajax call is successful. Can anyone give me a hint on how to do it?? My first call below:

var getUserInfo = $.ajax({
    type: "GET",
    url: "https://api.twitch.tv/helix/users/?login=ESL_SC2&login=freecodecamp&login=noobs2ninjas",
    // contentType: ('application/x-www-form-urlencoded; charset=UTF-8'),
    crossDomain: true,
    headers: {
        "Client-ID": "5k4g3q59o69v6p9tudn39v50ro1mux",
    },
    dataType: "json",
    success: function (json) {
        console.log(JSON.stringify(json, null, 2));
    },
    error: function () {
        console.log("OOPS!!!");
    },
})

The success function only runs if the call was successful.

Trigger the code for the second request from the success function.

The jQuery ajax function is built using the callback design to deal with its asynchronicity. You have two callbacks, success and error, one of which will fire when you receive a response from the Twitch API. If you want to make another ajax request depending on if your previous request was successful then you can simply write a very similar ajax request inside your success callback function pointing to the new location you are trying to acccess. I would recommend splitting that off into a separate function to maintain the readability of your code however.