playground network request

do not forget:

import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true

    func getAll(completion: @escaping (GetResourcesRequest<ResourceType>)->Void)
    {
        let dataTask = URLSession.shared.dataTask(with: resourceURL) {

            data , _, _ in
            //print("datatask \(data) b \(b) c \(c)")
            guard let jsonData = data else {
                completion(.failure)
                return
            }
            do {
                let resources = try JSONDecoder().decode([ResourceType].self, from: jsonData)
                completion(.success(resources ))
            }
            catch {
                completion(.failure)
            }
        }
        dataTask.resume()
    }

Tags: