Hi Paco,
I'm not from the official Google Ads Scripts Support team, but there's some room for improvement in your code.
Maybe you can try the code below?
If you want to remove the applied locations, you can extend the script with "location.remove();" in the while loop (see screenshot below).
Good luck!
Gr, Martijn
------------------------------
function main() {
var campaign = AdsApp
.campaigns()
.withIds([980722014])
.get();
var locations = campaign
.next()
.targeting()
.targetedLocations()
.get();
while (locations.hasNext()) {
var location = locations.next();
console.log(location.getName());
}
}
------------------------------