Angular Js/ Javascript execute a function until all the content of the array is being used

Question is how to assign data[“random_code”] to each random code from the array but not all at once. If data[“random_code”] has not value from the array it will execute Data.service and if response is 200 it will iterate to the next value and execute data service again and will wait for response 200 for the next untill all value from array is being used and then it will stop.

  let result = me.records.questionaires.map(a => a.random_code);
    var myStringArray = result
    console.log("List of Code", myStringArray)

reponse

List of Code (10) ["50-1118561158114", "50-111111118129911", "50-7111851035611", "50-95354410524", "50-2143566173", "50-49361157339", "50-2961010112644", "50-612511266113", "50-8381637318", "50-6819378387"]

interation part

for (var i = 0; i < arrayLength; i++) {
            data["users"] = me.records.shared_people
            data["random_code"] = myStringArray[i]   
            Data.service(me, data).then(function (response) {
                if (response.status == "200") {

                }
            })


        }

Source: AngularJS