func testData()->AnyPublisher<DemoObject, APIError> {
var data = DummyData().decodeClaimDetails()!
return (Just(data).eraseToAnyPublisher(),
APIError.httpError(200))
}
I got this error. Cannot convert return expression of type '(AnyPublisher<DemoObject, Never>, APIError)' to return type 'AnyPublisher<DemoObject, APIError>'
How can I return a type that is AnyPublisher<DemoObject, APIError>?
You want
func testData()->AnyPublisher<DemoObject, APIError> {
let d: DemoObject = // ...
return Just<DemoObject>(d)
.setFailureType(to: APIError.self) // <--
.eraseToAnyPublisher()
}
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