How would I convert this javascript load file function into something that takes in an image from a GET

const listenImageLoad = () => {
    document.getElementById("images").addEventListener("change", (event) => {
        const imageList = document.getElementById("imageList")

        const files = event.target.files

        if (files.length > 0) {
            resetImageList()

            for (let i = 0; i < files.length; i++) {
                const nameParts = files[i].name.split(".")

                if (extensions.indexOf(nameParts[nameParts.length - 1]) !== -1) {
                    images[files[i].name] = {
                        meta: files[i],
                        index: i
                    }
                }
            }

            const imageArray = Object.keys(images)

            let async = imageArray.length

            for (let image in images) {
                const reader = new FileReader()

                reader.addEventListener("load", () => {
                    const imageObject = new Image()

                    imageObject.addEventListener("load", (event) => {
                        images[image].width = event.target.width
                        images[image].height = event.target.height

                        if (--async === 0) {
                            document.body.style.cursor = "default"

                            setCurrentImage(images[imageArray[0]])

                        }
                    })

                    imageObject.src = reader.result
                })

                reader.readAsDataURL(images[image].meta)
            }
        }
    })
}

Here is the function above. This listens to Element to load images into the program. images is a global dict.

I see the first result of the imageArray being queried from the images dict and then being sent to the setCurrentImage(). Now were I to get an image from a GET, how would I fulfil all the requirements of this function, such as, getting the width and the height, before I pass this onto the setCurrentImage() function. If I don't want to mess with the original functionality of this program, I might as well call a loadImage() function and keep a single picture in it at all times.