Load images using webs urls with js

First of all I would like to inform that I’m very very new to JavaScript, I’ve been working on a super simple generator, basically all I want is to load an image from a random website on my html page using a form structure, using just vanilla JavaScript… I thought it was going to be easy but I cant seem to figure it out… This the code I’ve been working on:

document.getElementById(“byForm”).addEventListener(‘submit’, function(event) {

event.preventDefault();

let imageUrl = document.getElementById("imageLink").value;

let img = new Image();

img.src = imageUrl;

img.onload = function() {
    document.getElementById("imageContainer").appendChild(img);
};

})

The code above is the climax of several attempts that I’ve been trying on for the past few hours, created a div below the form application where the images are supposed to load in but nothing is happening. also the “imageLink” is the type=url id that i gave it. Can someone explain to me the correct way of doing this or if I’m missing something? Thanks!