How to rewrite sync method using SwiftUI?
There is no way to get a data from the inter/intranet synchronously you have to use an async method and account for the time it takes to download.
extension String {
    public func getUIImage() async throws -> UIImage {
        guard let url = URL(string: self) else {
            throw URLError(.badURL)
        }
        
        let (data, response) = try await URLSession.shared.data(from: url)
        
        guard let httpResponse = response as? HTTPURLResponse else {
            throw URLError(.badServerResponse)
        }
        
        guard httpResponse.statusCode == 200 else {
            throw URLError(URLError.Code(rawValue: httpResponse.statusCode))
        }
        
        guard let image = UIImage(data: data) else {
            throw URLError(.fileDoesNotExist)
        }
        return image
    }
}

extension UIImage {
    static public func fromURL(url: String) async throws -> UIImage {
        let image = try await url.getUIImage()
        return image
    }
}

You can rewrite PostView to something like.
struct PostView: View {
    let url: String
    @State private var uiImage: UIImage?
    var body: some View {
        Group{
            if let uiImage {
                PrivateImageView(image: uiImage)
            } else {
                ProgressView() //Show this while downloading
                    .task {
                        do {
                            self.uiImage = try await url.getUIImage()
                            // or
                            // self.uiImage = try await UIImage.fromURL(url: url)
                        } catch {
                            print(error)
                        }
                    }
            }
        }
    }
}


Now I'm using UIImage sync extension.
struct PostView: View {
    let url: String
    
    var body: some View {        
        PrivateImageView(image: UIImage(url:url))
     }
}

extension UIImage {
    public convenience init(url: String) {
        let url = URL(string: url)
        do {
            let data = try Data(contentsOf: url!)
            self.init(data: data)!
            return
        } catch let err {
            print("Error : \(err.localizedDescription)")
        }
        self.init()
    }
}

When I post a image, I got the error Synchronous URL loading of http://local.host/images/123.jpeg should not occur on this application's main thread as it may lead to UI unresponsiveness. Please switch to an asynchronous networking API such as URLSession. at try Data(contentsOf: url!).
In PostView I use PrivateImageView.
To use the view I have to designate the argument like this PrivateImageView(image: UIImage(xxxxxxxxx)).
I mean I have to use UIImage() not AsyncImage.
I don't know how to change convenience init to adjust to PrivateImageView.
Please tell me how to use an async function in this context.
