I have a view controller and a custom class to call APIs. One API doesn't return anything if it succeeds. I get empty response.
class APIManager {
static func callAPI(completion: @escaping ((Result</*Empty*/, Error>))) {
completion(.failure(Error()))
if statusCode == 200 {
completion(.success(/*Pass nothing*/))
}
}
}
I know I can use String
type and pass String
literal. Is there any better way?
You can use Void
as below,
static func callAPI(completion: @escaping (Result<Void, Error>) -> Void) {
if statusCode == 200 {
completion(.success(()))
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With