'Swift Continuations Error in Async Function

Hie, so I'm learning about Swift Continuations which I would like to implement. I'm following this Guide. I'm getting an error from code that I have copied as-is and I've found other implementations using the same format however I'm getting this error: Extra trailing closure passed in call

Here's the code:

 func fetchData() async throws -> Data {
        // instead of withCheckedContinuation, we are now calling withCheckedThrowingContinuation
        return try await withCheckedThrowingContinuation { continuation in
            fetchData { result in //ERROR IS HERE: Extra trailing closure passed in call
                switch result {
                case .success(let value):
                    continuation.resume(returning: value)
                case .failure(let error):
                    continuation.resume(throwing: error)
                }
            }
        }
    }


Sources

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

Source: Stack Overflow

Solution Source