UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to determine what the error is

Forums > SwiftUI

I have this function to fetch JSON data from a URL

   func fetch<T: Decodable>(_ url: URL, defaultValue:T, completion: @escaping (T) -> Void) {
        let decoder = JSONDecoder()
        URLSession.shared.dataTaskPublisher(for: url)
            .retry(1)
            .map(\.data)
             .decode(type: T.self, decoder: decoder)
           .replaceError(with: defaultValue)
            .receive(on: DispatchQueue.main)
            .sink(receiveCompletion: { (error) in
                print("fetch failed: \(String(describing: error))")
            }, receiveValue: completion
            )
            .store(in: &requests)
    }

This code has worked fine before when run against other web sites. When I run it against a new URL I get no data back and this message

2020-09-26 12:11:25.698193+0100 GameDetails[5624:453013] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed fetch failed: finished

The URL I am trying is: https://api.boardgameatlas.com/api/search?&client_id=JLBr5npPhV

I'm wondering what the error "finished" means, anyone got any ideas or something else I can try?

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.