Trying to parse a JSON and display the image from the JSON

Hi,

I have this code here, and I am really struggling with using SwiftUI and an MVVM architecture to display data from this https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY. I want to take the image URL passes through the JSON and display it. I Found https://medium.com/swift-productions/sdwebimageswiftui-image-from-url-b0960f0bda64 that shows how to use the SDWebView Swift package, and I would like to use this package to take the image URL that comes out of the JSON and display that image.

However, I am not sure how to setup my View Model... I made this app a bit ago that parses JSONs and puts them in a table, but when it seems like you have to setup your view model differently for creating a table compared to just displaying an image? Do any of you have any tips or resources I can look at ? thanks

This is not exactly what you are looking for, but if you need help downloading an image over the network, here is an example that should how to do so with URLSession. This of course does not show you the SwiftUI or MVVM portions of your question, but for the CFNetwork aspect it should get you started.

Trying to parse a JSON and display the image from the JSON
 
 
Q