You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue when mapping an image.
My service works when calling other data. Swapping out Moya with AlamoFireImage produces the desired results.
enum AvatarService {
case grabAvatarImage(url: String)
}
extension AvatarService: TargetType {
var baseURL: URL {
URL(string: "https://avatars.githubusercontent.com/u/")!
}
var path: String {
switch self {
case .grabAvatarImage(let url):
let splitUrl = url.components(separatedBy: "u/")
return splitUrl.last!
}
}
var method: Moya.Method { .get }
var task: Moya.Task { .requestPlain }
Calling from ViewModel:
func getLanguage() {
moya.provider.request(.grabAvatarImage(url: avatarUrl)) { [weak self] result in
switch result {
case .failure(let error):
print("Error fetching Image:", error)
case .success(let response):
guard
let self = self,
let receivedImage = try? response.mapImage()
else {
print("🔥 Failed to map image")
return
}
self.Image = receivedImage()
}
}
}
"🔥 Failed to map image" gets printed in console. Any help would be greatly appreciated. Thanks
Using Moya 15.0.0 via SwiftPackageManager
The text was updated successfully, but these errors were encountered:
I'm encountering an issue when mapping an image.
My service works when calling other data. Swapping out Moya with AlamoFireImage produces the desired results.
Calling from ViewModel:
"🔥 Failed to map image" gets printed in console. Any help would be greatly appreciated. Thanks
Using Moya 15.0.0 via SwiftPackageManager
The text was updated successfully, but these errors were encountered: