'Google Script says URL is empty

I'm trying to create a slide using Google Script, but I get the error "Exception: The URL should not be empty. (line 6, file "Code")"

The line is "var image = slide.insertImage(link);"

I managed to create the slide, but only with two blank pages

var NAME = "Teste Script Google";
var deck = SlidesApp.create(NAME); // SlidesApp.getActivePresentation();

function addImageSlide(link, index) {
  var slide = deck.appendSlide(SlidesApp.PredefinedLayout.BLANK);
  var image = slide.insertImage(link);
}

function main() {
  var images = [
    "https://www.portaldodog.com.br/cachorros/wp-content/uploads/2020/02/siberian-husky-4565849_1280.jpg",
    "https://love.doghero.com.br/wp-content/uploads/2018/12/golden-retriever-1.png",
  ];
  var [title, subtitle] = deck.getSlides()[0].getPageElements();
  title.asShape().getText().setText(NAME);
  subtitle.asShape().getText().setText("Google Aps Script\nSlides Service demo")
  images.forEach(addImagesSlide);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source